53 fail_unless(arch != NULL,
"Searching for an existing arch name (large city) should work");
54 fail_unless(!strcmp(arch->
clone.
name,
"large city"),
"Searching for an existing arch name shoud have returned us large city but returned %s", arch->
clone.
name);
56 fail_unless(arch != NULL,
"Searching for an existing arch name (Cloak of Magic Resistance) should work");
57 fail_unless(!strcmp(arch->
clone.
name,
"Cloak of Magic Resistance"),
"Searching for an existing arch name shoud have returned us Cloak of Magic Resistance but returned %s", arch->
clone.
name);
59 fail_unless(arch == NULL,
"Searching for an inexistant arch name (Cloak of Magic Resistanc) should return NULL");
61 fail_unless(arch == NULL,
"Searching for an inexistant arch name (some really non existant archetype) should return NULL");
63 fail_unless(arch == NULL,
"Searching for empty arch name should return NULL");
65 fail_unless(arch == NULL,
"Searching for NULL arch name should return NULL");
73 fail_unless(arch != NULL,
"Searching for an existing arch name (large city) + type (66) should work");
75 fail_unless(!strcmp(arch->
clone.
name,
"large city"),
"Searching for an existing arch name shoud have returned us large city but returned %s", arch->
clone.
name);
77 fail_unless(arch != NULL,
"Searching for an existing arch name (Cloak of Magic Resistance) + type (87) should work");
79 fail_unless(!strcmp(arch->
clone.
name,
"Cloak of Magic Resistance"),
"Searching for an existing arch name shoud have returned us Cloak of Magic Resistance but returned %s", arch->
clone.
name);
81 fail_unless(arch == NULL,
"Searching for an inexistant arch name (Cloak of Magic Resistanc) should return NULL");
83 fail_unless(arch == NULL,
"Searching for an existing arch name (Cloak of Magic Resistance) but with wrong type (88) should return NULL");
92 fail_unless(arch != NULL,
"Should be able to discover the alchemy skill");
93 fail_unless(!strcmp(arch->
name,
"skill_alchemy"),
"should have returned skill_alchemy but returned %s", arch->
name);
95 fail_unless(arch != NULL,
"Should be able to discover the scroll of alchemy skill or something similar");
97 fail_unless(arch != NULL,
"Should be able to discover something related to the 'one handed weapons' skill");
99 fail_unless(arch == NULL,
"Asking for null skill should return null");
107 fail_unless(arch != NULL,
"Should be able to find an arch of type SKILL, subtype SK_LITERACY");
108 fail_unless(arch->
clone.
type ==
SKILL,
"Arch of type SKILL, subtype SK_LITERACY shoud have type %d but has type %d",
SKILL, arch->
clone.
type);
110 fail_unless(arch != NULL,
"Should be able to find an arch of type quest, subtype SK_LITERACY");
112 fail_unless(arch != NULL,
"Should be able to find an arch of type SKILL, no subtype");
115 fail_unless(arch != NULL,
"Should be able to find an arch of type unknown, SK_LITERACY");
118 fail_unless(arch != NULL,
"Should be able to find arch of type unknown, subtype unknown, despite this being useless");
121 fail(
"Should be not able to find arch of inexistant type but got %p (%s)", arch, arch->
name);
130 fail_unless(ob != NULL,
"Should never return null");
132 fail_unless(!strncmp(ob->
name,
"writing pen", strlen(ob->
name)),
"Searching for writing pen should have returned something with same base name but returned '%s'", ob->
name);
134 fail_unless(ob != NULL,
"Should never return null");
136 fail_unless(!strncmp(ob->
name,
"writing pen of hell raiser +3", strlen(ob->
name)),
"Searching for writing pen of hell raiser +3 should have returned something with same base name but returned %s", ob->
name);
138 fail_unless(ob != NULL,
"Inexistent item shuold return a singularity");
141 fail_unless(ob != NULL,
"Inexistent item shuold return a singularity");
150 fail_unless(arch != NULL,
"init_archetype should have an 'empty_archetype' loaded");
164 fail_unless(arch == NULL,
"init_archetype should not have an 'empty_archetype' loaded after call to free_all_archs");
167 fail_unless(arch != NULL,
"init_archetype should have an 'empty_archetype' loaded");
174 fail_unless(arch != NULL,
"get_archetype_struct should not return NULL");
175 fail_unless(arch->
name == NULL,
"arch->name of get_archetype_struct should be inited to NULL");
176 fail_unless(arch->
head == NULL,
"arch->head of get_archetype_struct should be inited to NULL");
177 fail_unless(arch->
next == NULL,
"arch->next of get_archetype_struct should be inited to NULL");
178 fail_unless(arch->
more == NULL,
"arch->more of get_archetype_struct should be inited to NULL");
179 fail_unless(arch->
clone.
other_arch == NULL,
"arch->clone.other_arch of get_archetype_struct should be inited to NULL");
180 fail_unless(arch->
clone.
contr == NULL,
"arch->clone.contr of get_archetype_struct should be inited to NULL");
181 fail_unless(arch->
clone.
next == NULL,
"arch->clone.next of get_archetype_struct should be inited to NULL");
182 fail_unless(arch->
clone.
prev == NULL,
"arch->clone.prev of get_archetype_struct should be inited to NULL");
183 fail_unless(arch->
clone.
active_next == NULL,
"arch->clone.active_next of get_archetype_struct should be inited to NULL");
184 fail_unless(arch->
clone.
active_prev == NULL,
"arch->clone.active_prev of get_archetype_struct should be inited to NULL");
185 fail_unless(arch->
clone.
below == NULL,
"arch->clone.below of get_archetype_struct should be inited to NULL");
186 fail_unless(arch->
clone.
above == NULL,
"arch->clone.above of get_archetype_struct should be inited to NULL");
187 fail_unless(arch->
clone.
inv == NULL,
"arch->clone.inv of get_archetype_struct should be inited to NULL");
188 fail_unless(arch->
clone.
container == NULL,
"arch->clone.container of get_archetype_struct should be inited to NULL");
189 fail_unless(arch->
clone.
env == NULL,
"arch->clone.env of get_archetype_struct should be inited to NULL");
190 fail_unless(arch->
clone.
more == NULL,
"arch->clone.more of get_archetype_struct should be inited to NULL");
191 fail_unless(arch->
clone.
head == NULL,
"arch->clone.head of get_archetype_struct should be inited to NULL");
192 fail_unless(arch->
clone.
map == NULL,
"arch->clone.map of get_archetype_struct should be inited to NULL");
194 fail_unless(arch->
clone.
name == NULL,
"arch->clone.name of get_archetype_struct should be inited to NULL");
195 fail_unless(arch->
clone.
name_pl == NULL,
"arch->clone.name_pl of get_archetype_struct should be inited to NULL");
196 fail_unless(arch->
clone.
title == NULL,
"arch->clone.title of get_archetype_struct should be inited to NULL");
197 fail_unless(arch->
clone.
race == NULL,
"arch->clone.race of get_archetype_struct should be inited to NULL");
198 fail_unless(arch->
clone.
slaying == NULL,
"arch->clone.slaying of get_archetype_struct should be inited to NULL");
199 fail_unless(arch->
clone.
msg == NULL,
"arch->clone.msg of get_archetype_struct should be inited to NULL");
200 fail_unless(arch->
clone.
skill == NULL,
"arch->clone.skill of get_archetype_struct should be inited to NULL");
201 fail_unless(arch->
clone.
lore == NULL,
"arch->clone.lore of get_archetype_struct should be inited to NULL");
203 fail_unless(arch->
clone.
current_weapon == NULL,
"arch->clone.current_weapon of get_archetype_struct should be inited to NULL");
204 fail_unless(arch->
clone.
enemy == NULL,
"arch->clone.enemy of get_archetype_struct should be inited to NULL");
205 fail_unless(arch->
clone.
attacked_by == NULL,
"arch->clone.attacked_by of get_archetype_struct should be inited to NULL");
206 fail_unless(arch->
clone.
randomitems == NULL,
"arch->clone.randomitems of get_archetype_struct should be inited to NULL");
207 fail_unless(arch->
clone.
chosen_skill == NULL,
"arch->clone.chosen_skill of get_archetype_struct should be inited to NULL");
208 fail_unless(arch->
clone.
spellitem == NULL,
"arch->clone.spellitem of get_archetype_struct should be inited to NULL");
209 fail_unless(arch->
clone.
spell == NULL,
"arch->clone.spell of get_archetype_struct should be inited to NULL");
210 fail_unless(arch->
clone.
spellarg == NULL,
"arch->clone.spellarg of get_archetype_struct should be inited to NULL");
211 fail_unless(arch->
clone.
arch == arch,
"arch->clone.arch of get_archetype_struct should be inited to arch");
212 fail_unless(arch->
clone.
other_arch == NULL,
"arch->clone.other_arch of get_archetype_struct should be inited to NULL");
213 fail_unless(arch->
clone.
custom_name == NULL,
"arch->clone.custom_name of get_archetype_struct should be inited to NULL");
214 fail_unless(arch->
clone.
key_values == NULL,
"arch->clone.key_values of get_archetype_struct should be inited to NULL");
224 fail_unless(obj != NULL,
"instanciating an arch should not return null");
232 fail_unless(obj != NULL,
"create_singularity should not return null");
233 fail_unless(strstr(obj->
name,
"XYZABCD") != NULL,
"create_singularity(\"XYZABCD\") should put XYZABCD somewhere in singularity name");
241 fail_unless(obj != NULL,
"create_archetype(\"empty_archetype\") should not return null");
249 fail_unless(arch != NULL,
"find_archetype(\"empty_archetype\") should not return null");
251 fail_unless(arch != NULL,
"find_archetype(\"elvenboots\") should not return null");
253 fail_unless(arch == NULL,
"find_archetype(\"AA1234567890\") should return null");
263 fail_unless(obj != NULL,
"Should be able to fully instanciate the dark_palace");
264 fail_unless(obj->
head == NULL,
"The object is full, so we should have got it's head. So head should be null but was %p for object %p", obj->
head, obj);
265 fail_unless(obj->
more != NULL,
"The object is full and multisquare, so more should not return null");
270 Suite *s = suite_create(
"arch");
271 TCase *tc_core = tcase_create(
"Core");
276 suite_add_tcase(s, tc_core);
277 tcase_add_test(tc_core, test_find_archetype_by_object_name);
278 tcase_add_test(tc_core, test_find_archetype_by_object_type_name);
279 tcase_add_test(tc_core, test_get_archetype_by_skill_name);
280 tcase_add_test(tc_core, test_get_archetype_by_type_subtype);
281 tcase_add_test(tc_core, test_create_archetype_by_object_name);
282 tcase_add_test(tc_core, test_init_archetypes);
283 tcase_add_test(tc_core, test_clear_archetable);
284 tcase_add_test(tc_core, test_free_all_archs);
285 tcase_add_test(tc_core, test_get_archetype_struct);
286 tcase_add_test(tc_core, test_arch_to_object);
287 tcase_add_test(tc_core, test_create_singularity);
288 tcase_add_test(tc_core, test_create_archetype);
289 tcase_add_test(tc_core, test_find_archetype);
290 tcase_add_test(tc_core, test_object_create_arch);
298 SRunner *sr = srunner_create(s);
300 srunner_set_xml(sr, LOGDIR
"/unit/common/arch.xml");
301 srunner_set_log(sr, LOGDIR
"/unit/common/arch.out");
302 srunner_run_all(sr, CK_ENV);
303 nf = srunner_ntests_failed(sr);
305 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
archetype * find_archetype(const char *name)
END_TEST Suite * arch_suite(void)
START_TEST(test_find_archetype_by_object_name)
object * create_singularity(const char *name)
struct treasureliststruct * randomitems
void init_archetypes(void)
object * create_archetype_by_object_name(const char *name)
struct archt * other_arch
archetype * find_archetype_by_object_type_name(int type, const char *name)
struct obj * chosen_skill
void clear_archetable(void)
object * create_archetype(const char *name)
archetype * get_archetype_by_skill_name(const char *skill, int type)
archetype * find_archetype_by_object_name(const char *name)
struct obj * current_weapon
object * object_create_arch(archetype *at)
void free_all_archs(void)
archetype * get_archetype_by_type_subtype(int type, int subtype)
object * arch_to_object(archetype *at)
archetype * get_archetype_struct(void)