Crossfire Server, Trunk
check_883.c
Go to the documentation of this file.
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 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_apply) {
42  object *monster;
43  object *sword;
44 
45  monster = create_archetype("goblin");
46  fail_unless(monster, "couldn't create goblin");
47  sword = create_archetype("sword");
48  fail_unless(sword, "couldn't create sword");
49 
50  object_insert_in_ob(sword, monster);
51  monster_check_apply_all(monster);
52 
53  fail_unless(QUERY_FLAG(sword, FLAG_APPLIED), "sword should be applied");
54 }
55 END_TEST
56 
57 static Suite *bug_suite(void) {
58  Suite *s = suite_create("bug");
59  TCase *tc_core = tcase_create("Core");
60 
61  tcase_add_checked_fixture(tc_core, setup, teardown);
62 
63  suite_add_tcase(s, tc_core);
64  tcase_add_test(tc_core, test_apply);
65  tcase_set_timeout(tc_core, 0);
66 
67  return s;
68 }
69 
70 int main(void) {
71  int nf;
72  Suite *s = bug_suite();
73  SRunner *sr = srunner_create(s);
74 
75  srunner_set_fork_status(sr, CK_NOFORK);
76  cctk_setdatadir(SOURCE_ROOT "lib");
77  init(0, NULL);
78 
79  srunner_set_xml(sr, LOGDIR "/bugs/bugtrack/883.xml");
80  srunner_set_log(sr, LOGDIR "/bugs/bugtrack/883.out");
81  srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
82  nf = srunner_ntests_failed(sr);
83  srunner_free(sr);
84  return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
85 }
global.h
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.c:69
teardown
static void teardown(void)
Definition: check_883.c:38
main
int main(void)
Definition: check_883.c:70
FLAG_APPLIED
#define FLAG_APPLIED
Definition: define.h:235
toolkit_common.h
sproto.h
START_TEST
START_TEST(test_apply)
Definition: check_883.c:41
create_archetype
object * create_archetype(const char *name)
Definition: arch.cpp:281
monster_check_apply_all
void monster_check_apply_all(object *monster)
Definition: monster.c:1991
bug_suite
static END_TEST Suite * bug_suite(void)
Definition: check_883.c:57
init
void init(int argc, char **argv)
Definition: init.c:1108
object_insert_in_ob
object * object_insert_in_ob(object *op, object *where)
Definition: object.c:2833
setup
static void setup(void)
Definition: check_883.c:35