Crossfire Server, Trunk
check_2879249.cpp
Go to the documentation of this file.
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 crossfire-devel@real-time.com
21  */
22 
29 #include <stdlib.h>
30 #include <check.h>
31 #include <global.h>
32 #include <sproto.h>
33 #include <toolkit_common.h>
34 
35 static void setup(void) {
36 }
37 
38 static void teardown(void) {
39 }
40 
41 START_TEST(test_insert) {
42  mapstruct *map1;
43  archetype *big_galleon_arch;
44  object *big_galleon;
45  object *ob;
46 
47  map1 = ready_map_name("/world/world_103_128", 0);
48  fail_unless(map1 != NULL, "cannot load map /world/world_103_128");
49 
50  big_galleon_arch = find_archetype("big_galleon");
51  fail_unless(big_galleon_arch != NULL, "cannot find archetype big_galleon");
52  big_galleon = object_create_arch(big_galleon_arch);
53  fail_unless(big_galleon != NULL, "cannot create object big_galleon");
54 
55  for (ob = big_galleon; ob != NULL; ob = ob->more)
56  if (ob->arch->clone.x > 0)
57  break;
58  fail_unless(ob != NULL, "big_galleon's height must be at least two");
59  object_insert_in_map_at(big_galleon, map1, NULL, 0, map1->width/2, map1->height-1);
60  for (ob = big_galleon; ob != NULL; ob = ob->more)
61  fail_unless(ob->map != NULL);
62 }
63 END_TEST
64 
65 static Suite *bug_suite(void) {
66  Suite *s = suite_create("bug");
67  TCase *tc_core = tcase_create("Core");
68 
69  tcase_add_checked_fixture(tc_core, setup, teardown);
70 
71  suite_add_tcase(s, tc_core);
72  tcase_add_test(tc_core, test_insert);
73  tcase_set_timeout(tc_core, 0);
74 
75  return s;
76 }
77 
78 int main(void) {
79  int nf;
80  Suite *s = bug_suite();
81  SRunner *sr = srunner_create(s);
82 
83  srunner_set_fork_status(sr, CK_NOFORK);
84  cctk_setdatadir(SOURCE_ROOT "lib");
85  init(0, NULL);
86 
87  srunner_set_xml(sr, LOGDIR "/bugs/bugtrack/2879249.xml");
88  srunner_set_log(sr, LOGDIR "/bugs/bugtrack/2879249.out");
89  srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
90  nf = srunner_ntests_failed(sr);
91  srunner_free(sr);
92  return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
93 }
global.h
ready_map_name
mapstruct * ready_map_name(const char *name, int flags)
Definition: map.cpp:1793
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.cpp:69
guildjoin.ob
ob
Definition: guildjoin.py:42
mapstruct::height
uint16_t height
Definition: map.h:339
mapstruct::width
uint16_t width
Definition: map.h:339
main
int main(void)
Definition: check_2879249.cpp:78
toolkit_common.h
object_create_arch
object * object_create_arch(archetype *at)
Definition: arch.cpp:298
bug_suite
static END_TEST Suite * bug_suite(void)
Definition: check_2879249.cpp:65
archetype
Definition: object.h:472
sproto.h
object_insert_in_map_at
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Definition: object.cpp:2098
mapstruct
Definition: map.h:316
setup
static void setup(void)
Definition: check_2879249.cpp:35
find_archetype
archetype * find_archetype(const char *name)
Definition: assets.cpp:266
START_TEST
START_TEST(test_insert)
Definition: check_2879249.cpp:41
init
void init(int argc, char **argv)
Definition: init.cpp:1079
teardown
static void teardown(void)
Definition: check_2879249.cpp:38