Crossfire Server, Trunk
check_artifact.cpp
Go to the documentation of this file.
1 /*
2  * CrossFire, A Multiplayer game for X-windows
3  *
4  * Copyright (C) 2022 the 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 
23 /*
24  * This is the unit tests file for common/artifact.c
25  */
26 
27 #include <global.h>
28 #include <stdlib.h>
29 #include <check.h>
30 #include <loader.h>
31 #include <toolkit_common.h>
32 
33 static void setup(void) {
34  cctk_setdatadir(SOURCE_ROOT"lib");
35  cctk_setlog(LOGDIR"/unit/common/artifact.out");
37 }
38 
39 static void teardown(void) {
40  /* put any cleanup steps here, they will be run after each testcase */
41 }
42 
44 START_TEST(test_face_for_each_artifact) {
45  const artifactlist *al;
46  const artifact *art;
47  al = first_artifactlist;
48  while (al) {
49  art = al->items;
50  while (art) {
51  fail_unless(artifact_get_face(art) != (uint16_t)-1, "failed to find a face for %s", art->item->name);
52  art = art->next;
53  }
54  al = al->next;
55  }
56 }
57 END_TEST
58 
59 static Suite *artifact_suite(void) {
60  Suite *s = suite_create("artifact");
61  TCase *tc_core = tcase_create("Core");
62  tcase_set_timeout(tc_core, 60);
63 
64  /*setup and teardown will be called before each test in testcase 'tc_core' */
65  tcase_add_checked_fixture(tc_core, setup, teardown);
66 
67  suite_add_tcase(s, tc_core);
68  tcase_add_test(tc_core, test_face_for_each_artifact);
69 
70  return s;
71 }
72 
73 int main(void) {
74  int nf;
75  Suite *s = artifact_suite();
76  SRunner *sr = srunner_create(s);
77 
78  srunner_set_xml(sr, LOGDIR "/unit/common/artifact.xml");
79  srunner_set_log(sr, LOGDIR "/unit/common/artifact.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
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.cpp:69
artifactliststruct::items
struct artifactstruct * items
Definition: artifact.h:30
START_TEST
START_TEST(test_face_for_each_artifact)
Definition: check_artifact.cpp:44
toolkit_common.h
obj::name
sstring name
Definition: object.h:317
cctk_setlog
void cctk_setlog(const char *logfile)
Definition: toolkit_common.cpp:64
artifactstruct::next
struct artifactstruct * next
Definition: artifact.h:18
artifact_suite
static END_TEST Suite * artifact_suite(void)
Definition: check_artifact.cpp:59
artifactliststruct::next
struct artifactliststruct * next
Definition: artifact.h:29
main
int main(void)
Definition: check_artifact.cpp:73
artifactliststruct
Definition: artifact.h:26
artifactstruct
Definition: artifact.h:14
cctk_init_std_archetypes
void cctk_init_std_archetypes(void)
Definition: toolkit_common.cpp:83
artifact_get_face
uint16_t artifact_get_face(const artifact *art)
Definition: artifact.cpp:642
first_artifactlist
artifactlist * first_artifactlist
Definition: init.cpp:109
artifactstruct::item
object * item
Definition: artifact.h:15
loader.h
teardown
static void teardown(void)
Definition: check_artifact.cpp:39
setup
static void setup(void)
Definition: check_artifact.cpp:33