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");
85 FAIL_UNLESS(
arch == NULL,
"Searching for type with NULL name should return NULL");
94 FAIL_UNLESS(
arch != NULL,
"Should be able to discover the alchemy skill");
95 FAIL_UNLESS(!strcmp(
arch->name,
"skill_alchemy"),
"should have returned skill_alchemy but returned %s",
arch->name);
97 FAIL_UNLESS(
arch != NULL,
"Should be able to discover the scroll of alchemy skill or something similar");
99 FAIL_UNLESS(
arch != NULL,
"Should be able to discover something related to the 'one handed weapons' skill");
109 FAIL_UNLESS(
arch != NULL,
"Should be able to find an arch of type SKILL, subtype SK_LITERACY");
110 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);
113 FAIL_UNLESS(
arch != NULL,
"Should be able to find an arch of type SKILL, no subtype");
116 FAIL_UNLESS(
arch != NULL,
"Should be able to find an arch of type unknown, SK_LITERACY");
119 FAIL_UNLESS(
arch != NULL,
"Should be able to find arch of type unknown, subtype unknown, despite this being useless");
121 FAIL_UNLESS(
arch == NULL,
"Should be not able to find arch of inexistant type but got %p (%s)",
arch,
arch->name);
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);
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");
157 FAIL_UNLESS(
arch != NULL,
"get_archetype_struct should not return NULL");
158 FAIL_UNLESS(
arch->name == NULL,
"arch->name of get_archetype_struct should be inited to NULL");
159 FAIL_UNLESS(
arch->head == NULL,
"arch->head of get_archetype_struct should be inited to NULL");
160 FAIL_UNLESS(
arch->more == NULL,
"arch->more of get_archetype_struct should be inited to NULL");
161 FAIL_UNLESS(
arch->clone.other_arch == NULL,
"arch->clone.other_arch of get_archetype_struct should be inited to NULL");
162 FAIL_UNLESS(
arch->clone.contr == NULL,
"arch->clone.contr of get_archetype_struct should be inited to NULL");
163 FAIL_UNLESS(
arch->clone.next == NULL,
"arch->clone.next of get_archetype_struct should be inited to NULL");
164 FAIL_UNLESS(
arch->clone.prev == NULL,
"arch->clone.prev of get_archetype_struct should be inited to NULL");
165 FAIL_UNLESS(
arch->clone.active_next == NULL,
"arch->clone.active_next of get_archetype_struct should be inited to NULL");
166 FAIL_UNLESS(
arch->clone.active_prev == NULL,
"arch->clone.active_prev of get_archetype_struct should be inited to NULL");
167 FAIL_UNLESS(
arch->clone.below == NULL,
"arch->clone.below of get_archetype_struct should be inited to NULL");
168 FAIL_UNLESS(
arch->clone.above == NULL,
"arch->clone.above of get_archetype_struct should be inited to NULL");
169 FAIL_UNLESS(
arch->clone.inv == NULL,
"arch->clone.inv of get_archetype_struct should be inited to NULL");
170 FAIL_UNLESS(
arch->clone.container == NULL,
"arch->clone.container of get_archetype_struct should be inited to NULL");
171 FAIL_UNLESS(
arch->clone.env == NULL,
"arch->clone.env of get_archetype_struct should be inited to NULL");
172 FAIL_UNLESS(
arch->clone.more == NULL,
"arch->clone.more of get_archetype_struct should be inited to NULL");
173 FAIL_UNLESS(
arch->clone.head == NULL,
"arch->clone.head of get_archetype_struct should be inited to NULL");
174 FAIL_UNLESS(
arch->clone.map == NULL,
"arch->clone.map of get_archetype_struct should be inited to NULL");
176 FAIL_UNLESS(
arch->clone.name == NULL,
"arch->clone.name of get_archetype_struct should be inited to NULL");
177 FAIL_UNLESS(
arch->clone.name_pl == NULL,
"arch->clone.name_pl of get_archetype_struct should be inited to NULL");
178 FAIL_UNLESS(
arch->clone.title == NULL,
"arch->clone.title of get_archetype_struct should be inited to NULL");
179 FAIL_UNLESS(
arch->clone.race == NULL,
"arch->clone.race of get_archetype_struct should be inited to NULL");
180 FAIL_UNLESS(
arch->clone.slaying == NULL,
"arch->clone.slaying of get_archetype_struct should be inited to NULL");
181 FAIL_UNLESS(
arch->clone.msg == NULL,
"arch->clone.msg of get_archetype_struct should be inited to NULL");
182 FAIL_UNLESS(
arch->clone.skill == NULL,
"arch->clone.skill of get_archetype_struct should be inited to NULL");
183 FAIL_UNLESS(
arch->clone.lore == NULL,
"arch->clone.lore of get_archetype_struct should be inited to NULL");
185 FAIL_UNLESS(
arch->clone.current_weapon == NULL,
"arch->clone.current_weapon of get_archetype_struct should be inited to NULL");
186 FAIL_UNLESS(
arch->clone.enemy == NULL,
"arch->clone.enemy of get_archetype_struct should be inited to NULL");
187 FAIL_UNLESS(
arch->clone.attacked_by == NULL,
"arch->clone.attacked_by of get_archetype_struct should be inited to NULL");
188 FAIL_UNLESS(
arch->clone.randomitems == NULL,
"arch->clone.randomitems of get_archetype_struct should be inited to NULL");
189 FAIL_UNLESS(
arch->clone.chosen_skill == NULL,
"arch->clone.chosen_skill of get_archetype_struct should be inited to NULL");
190 FAIL_UNLESS(
arch->clone.spellitem == NULL,
"arch->clone.spellitem of get_archetype_struct should be inited to NULL");
191 FAIL_UNLESS(
arch->clone.spell == NULL,
"arch->clone.spell of get_archetype_struct should be inited to NULL");
192 FAIL_UNLESS(
arch->clone.spellarg == NULL,
"arch->clone.spellarg of get_archetype_struct should be inited to NULL");
193 FAIL_UNLESS(
arch->clone.arch ==
arch,
"arch->clone.arch of get_archetype_struct should be inited to arch");
194 FAIL_UNLESS(
arch->clone.other_arch == NULL,
"arch->clone.other_arch of get_archetype_struct should be inited to NULL");
195 FAIL_UNLESS(
arch->clone.key_values == NULL,
"arch->clone.key_values of get_archetype_struct should be inited to NULL");
205 FAIL_UNLESS(
obj != NULL,
"instanciating an arch should not return null");
213 FAIL_UNLESS(
obj != NULL,
"create_singularity should not return null");
214 FAIL_UNLESS(strstr(
obj->name,
"XYZABCD") != NULL,
"create_singularity(\"XYZABCD\") should put XYZABCD somewhere in singularity name");
222 FAIL_UNLESS(
obj != NULL,
"create_archetype(\"empty_archetype\") should not return null");
230 FAIL_UNLESS(
arch != NULL,
"find_archetype(\"empty_archetype\") should not return null");
232 FAIL_UNLESS(
arch != NULL,
"find_archetype(\"elvenboots\") should not return null");
234 FAIL_UNLESS(
arch != NULL,
"find_archetype(\"AA1234567890\") should not return null");
244 FAIL_UNLESS(
obj != NULL,
"Should be able to fully instanciate the dark_palace");
245 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);
246 FAIL_UNLESS(
obj->more != NULL,
"The object is full and multisquare, so more should not return null");
251 Suite *s = suite_create(
"arch");
252 TCase *tc_core = tcase_create(
"Core");
253 tcase_set_timeout(tc_core, 60);
258 suite_add_tcase(s, tc_core);
259 tcase_add_test(tc_core, test_find_archetype_by_object_name);
260 tcase_add_test(tc_core, test_find_archetype_by_object_type_name);
261 tcase_add_test(tc_core, test_get_archetype_by_skill_name);
262 tcase_add_test(tc_core, test_get_archetype_by_type_subtype);
263 tcase_add_test(tc_core, test_create_archetype_by_object_name);
264 tcase_add_test(tc_core, test_init_archetypes);
265 tcase_add_test(tc_core, test_get_archetype_struct);
266 tcase_add_test(tc_core, test_arch_to_object);
267 tcase_add_test(tc_core, test_create_singularity);
268 tcase_add_test(tc_core, test_create_archetype);
269 tcase_add_test(tc_core, test_find_archetype);
270 tcase_add_test(tc_core, test_object_create_arch);
278 SRunner *sr = srunner_create(s);
280 srunner_set_xml(sr, LOGDIR
"/unit/common/arch.xml");
281 srunner_set_log(sr, LOGDIR
"/unit/common/arch.out");
282 srunner_run_all(sr, CK_ENV);
283 nf = srunner_ntests_failed(sr);
285 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;