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  al = first_artifactlist;
47  while (al) {
48  for (auto art : al->items) {
49  fail_unless(artifact_get_face(art) != (uint16_t)-1, "failed to find a face for %s", art->item->name);
50  }
51  al = al->next;
52  }
53 }
54 END_TEST
55 
56 static Suite *artifact_suite(void) {
57  Suite *s = suite_create("artifact");
58  TCase *tc_core = tcase_create("Core");
59  tcase_set_timeout(tc_core, 60);
60 
61  /*setup and teardown will be called before each test in testcase 'tc_core' */
62  tcase_add_checked_fixture(tc_core, setup, teardown);
63 
64  suite_add_tcase(s, tc_core);
65  tcase_add_test(tc_core, test_face_for_each_artifact);
66 
67  return s;
68 }
69 
70 int main(void) {
71  int nf;
72  Suite *s = artifact_suite();
73  SRunner *sr = srunner_create(s);
74 
75  srunner_set_xml(sr, LOGDIR "/unit/common/artifact.xml");
76  srunner_set_log(sr, LOGDIR "/unit/common/artifact.out");
77  srunner_run_all(sr, CK_ENV); /*verbosity from env variable*/
78  nf = srunner_ntests_failed(sr);
79  srunner_free(sr);
80  return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
81 }
global.h
cctk_setdatadir
void cctk_setdatadir(const char *datadir)
Definition: toolkit_common.cpp:69
artifactlist::items
std::vector< artifact * > items
Definition: artifact.h:28
artifactlist::next
artifactlist * next
Definition: artifact.h:27
START_TEST
START_TEST(test_face_for_each_artifact)
Definition: check_artifact.cpp:44
toolkit_common.h
cctk_setlog
void cctk_setlog(const char *logfile)
Definition: toolkit_common.cpp:64
artifact_suite
static END_TEST Suite * artifact_suite(void)
Definition: check_artifact.cpp:56
main
int main(void)
Definition: check_artifact.cpp:70
artifactlist
Definition: artifact.h:24
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:638
first_artifactlist
artifactlist * first_artifactlist
Definition: init.cpp:109
loader.h
teardown
static void teardown(void)
Definition: check_artifact.cpp:39
setup
static void setup(void)
Definition: check_artifact.cpp:33