Crossfire Server, Trunk
check_recipe.cpp
Go to the documentation of this file.
1 /*
2  * static char *rcsid_check_recipe_c =
3  * "$Id$";
4  */
5 
6 /*
7  * CrossFire, A Multiplayer game for X-windows
8  *
9  * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  * Copyright (C) 1992 Frank Tore Johansen
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  *
26  * The authors can be reached via e-mail at crossfire-devel@real-time.com
27  */
28 
29 /*
30  * This is the unit tests file for common/recipe.c
31  */
32 
33 #include <stdlib.h>
34 #include <check.h>
35 
36 #include "global.h"
37 #include <toolkit_common.h>
38 
39 void setup(void) {
40  cctk_setdatadir(SOURCE_ROOT"lib");
41  cctk_setlog(LOGDIR"/unit/common/arch.out");
43 }
44 
45 void teardown(void) {
46  /* put any cleanup steps here, they will be run after each testcase */
47 }
48 
49 START_TEST(test_check_recipes) {
50  FAIL_UNLESS(check_recipes(), "check_recipes failed");
51 }
52 END_TEST
53 
54 START_TEST(test_check_formulae) {
55  FAIL_UNLESS(check_formulae(), "check_formulae failed");
56 }
57 END_TEST
58 
59 Suite *recipe_suite(void) {
60  Suite *s = suite_create("recipe");
61  TCase *tc_core = tcase_create("Core");
62 
63  /*setup and teardown will be called before each test in testcase 'tc_core' */
64  tcase_add_checked_fixture(tc_core, setup, teardown);
65 
66  suite_add_tcase(s, tc_core);
67  tcase_add_test(tc_core, test_check_recipes);
68  tcase_add_test(tc_core, test_check_formulae);
69 
70  return s;
71 }
72 
73 int main(void) {
74  int nf;
75  Suite *s = recipe_suite();
76  SRunner *sr = srunner_create(s);
77 
78  srunner_set_xml(sr, LOGDIR "/unit/common/recipe.xml");
79  srunner_set_log(sr, LOGDIR "/unit/common/recipe.out");
80  srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
81  nf = srunner_ntests_failed(sr);
82  srunner_free(sr);
83  return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
84 }
global.h
setup
void setup(void)
Definition: check_recipe.cpp:39
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.cpp:69
START_TEST
START_TEST(test_check_recipes)
Definition: check_recipe.cpp:49
check_recipes
bool check_recipes()
Definition: recipe.cpp:147
FAIL_UNLESS
#define FAIL_UNLESS(expr,...)
Definition: toolkit_common.h:11
toolkit_common.h
cctk_setlog
void cctk_setlog(const char *logfile)
Definition: toolkit_common.cpp:64
check_formulae
bool check_formulae(void)
Definition: recipe.cpp:292
main
int main(void)
Definition: check_recipe.cpp:73
recipe_suite
END_TEST Suite * recipe_suite(void)
Definition: check_recipe.cpp:59
teardown
void teardown(void)
Definition: check_recipe.cpp:45
cctk_init_std_archetypes
void cctk_init_std_archetypes(void)
Definition: toolkit_common.cpp:83