Debian Codegraph @

test/bugs/bugtrack/check_2879249.c

raw symbols SCIP
1 /*
2 * CrossFire, A Multiplayer game for X-windows
3 *
4 * Copyright (C) 2009 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 * This is the unit tests file for the bug #2879249: SIGSEGV on transport
26 * moving across some edges of tiled maps.
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_insert) {
41 mapstruct *map1;
42 archetype *big_galleon_arch;
43 object *big_galleon;
44 object *ob;
45
46 map1 = ready_map_name("/world/world_103_128", 0);
47 fail_unless(map1 != NULL, "cannot load map /world/world_103_128");
48
49 big_galleon_arch = find_archetype("big_galleon");
50 fail_unless(big_galleon_arch != NULL, "cannot find archetype big_galleon");
51 big_galleon = object_create_arch(big_galleon_arch);
52 fail_unless(big_galleon != NULL, "cannot create object big_galleon");
53
54 for (ob = big_galleon; ob != NULL; ob = ob->more)
55 if (ob->arch->clone.x > 0)
56 break;
57 fail_unless(ob != NULL, "big_galleon's height must be at least two");
58 object_insert_in_map_at(big_galleon, map1, NULL, 0, map1->width/2, map1->height-1);
59 for (ob = big_galleon; ob != NULL; ob = ob->more)
60 fail_unless(ob->map != NULL);
61 }
62 END_TEST
63
64 static Suite *bug_suite(void) {
65 Suite *s = suite_create("bug");
66 TCase *tc_core = tcase_create("Core");
67
68 tcase_add_checked_fixture(tc_core, setup, teardown);
69
70 suite_add_tcase(s, tc_core);
71 tcase_add_test(tc_core, test_insert);
72 tcase_set_timeout(tc_core, 0);
73
74 return s;
75 }
76
77 int main(void) {
78 int nf;
79 Suite *s = bug_suite();
80 SRunner *sr = srunner_create(s);
81
82 srunner_set_fork_status(sr, CK_NOFORK);
83 init(0, NULL);
84
85 srunner_set_xml(sr, LOGDIR "/bugs/bugtrack/2879249.xml");
86 srunner_set_log(sr, LOGDIR "/bugs/bugtrack/2879249.out");
87 srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
88 nf = srunner_ntests_failed(sr);
89 srunner_free(sr);
90 return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
91 }