Crossfire Server, Trunk  R20513
check_2879249.c
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 
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 }
archetype * find_archetype(const char *name)
Finds, using the hashtable, which archetype matches the given name.
Definition: arch.c:695
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
Definition: map.c:1803
object clone
An object from which to do object_copy()
Definition: object.h:470
Global type definitions and header inclusions.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
uint16_t height
Width and height of map.
Definition: map.h:347
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.c:1921
START_TEST(test_insert)
Definition: check_2879249.c:40
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
void init(int argc, char **argv)
This is the main server initialization function.
Definition: init.c:978
object * object_create_arch(archetype *at)
Create a full object using the given archetype.
Definition: arch.c:736
int16_t x
Definition: object.h:326
static void teardown(void)
Definition: check_2879249.c:37
struct archt * arch
Pointer to archetype.
Definition: object.h:412
uint16_t width
Definition: map.h:347
int main(void)
Definition: check_2879249.c:77
static void setup(void)
Definition: check_2879249.c:34
static END_TEST Suite * bug_suite(void)
Definition: check_2879249.c:64
This is a game-map.
Definition: map.h:325
struct obj * more
Pointer to the rest of a large body of objects.
Definition: object.h:295