Debian Codegraph @

test/bugs/bugtrack/check_883.c

raw symbols SCIP
1 /*
2 * CrossFire, A Multiplayer game for X-windows
3 *
4 * Copyright (C) 2020 Crossfire Development Team
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * The authors can be reached via e-mail at [email protected]
21 */
22
23 /**
24 * @file
25 * Unit test for bug https://sourceforge.net/p/crossfire/bugs/883/
26 * Monsters will not apply weapons in their inventory
27 */
28
29 #include <stdlib.h>
30 #include <check.h>
31 #include <global.h>
32 #include <sproto.h>
33
34 static void setup(void) {
35 }
36
37 static void teardown(void) {
38 }
39
40 START_TEST(test_apply) {
41 object *monster;
42 object *sword;
43
44 monster = create_archetype("goblin");
45 fail_unless(monster, "couldn't create goblin");
46 sword = create_archetype("sword");
47 fail_unless(sword, "couldn't create sword");
48
49 object_insert_in_ob(sword, monster);
50 monster_check_apply_all(monster);
51
52 fail_unless(QUERY_FLAG(sword, FLAG_APPLIED), "sword should be applied");
53 }
54 END_TEST
55
56 static Suite *bug_suite(void) {
57 Suite *s = suite_create("bug");
58 TCase *tc_core = tcase_create("Core");
59
60 tcase_add_checked_fixture(tc_core, setup, teardown);
61
62 suite_add_tcase(s, tc_core);
63 tcase_add_test(tc_core, test_apply);
64 tcase_set_timeout(tc_core, 0);
65
66 return s;
67 }
68
69 int main(void) {
70 int nf;
71 Suite *s = bug_suite();
72 SRunner *sr = srunner_create(s);
73
74 srunner_set_fork_status(sr, CK_NOFORK);
75 init(0, NULL);
76
77 srunner_set_xml(sr, LOGDIR "/bugs/bugtrack/883.xml");
78 srunner_set_log(sr, LOGDIR "/bugs/bugtrack/883.out");
79 srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
80 nf = srunner_ntests_failed(sr);
81 srunner_free(sr);
82 return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
83 }