56 static const char *archs[] = {
67 "helmet_of_brilliance",
92 static const char *arch_results[] = {
99 "(slow movement)(wield weapon)(archer)(wear armour)(wear ring)",
101 "(dam+6)(weapon speed 10)(Attacks: physical)",
102 "(wc+1)(dam+15)(Firing delay 1.43)(Attacks: physical)",
103 "(Int+2)(Pow+2)(ac+2)(item_power +5)(magic+1)[color=#FF15CD](armour +5)[/color]",
104 "(Str+1)(Wis+2)(Cha+2)(dam+15)(item_power +25)(weapon speed 6)(Attacks: weaponmagic, blinding)[color=#930C76](resist magic +30)[/color][ul](resist drain +100)[/ul]",
105 "(dam+8)(weapon speed 8)(Attacks: physical)",
106 "(ac+1)[color=#FF15CD](armour +5)[/color]",
108 "(food+65)(slay vial_poison:poison)",
110 "(extremely fast movement)(undead)(spellcaster)(Spell abilities:)(paralyze)(fear ability)(cause black death)(cause red death)(face of death)(meteor swarm)(hellfire)(burning hands)(large fireball)(mass confusion)(negative energy bolt)(negative energy ball)(slow ability)(Attacks: physical, cold)(armour +75)(resist magic +100)(resist fire +100)(resist electricity +90)(resist cold +100)(resist confusion +100)(resist acid +90)(resist drain +100)(resist weaponmagic +80)(resist ghosthit +100)(resist poison +100)(resist slow +100)(resist paralyzation +100)(resist fear +100)(resist cancellation +65)(resist depletion +100)(resist death +100)(resist chaos +100)(resist counterspell +65)(resist god power +80)(resist blindness +100)",
111 "(slow movement)(undead)(Attacks: physical)(resist cold +50)(resist fear +100)",
114 "(normal movement)(see invisible)(spellcaster)(Spell abilities:)(breath flame)(medium fireball ability)(fear ability)(Attacks: physical)(resist fire +100)(resist cold -100)(resist confusion -100)(resist fear +100)(resist blindness +50)",
115 "(fast movement)(see invisible)(wield weapon)(archer)(wear armour)(wear ring)(read scroll)(fires wand/rod/horn)(spellcaster)(Spell abilities:)(paralyze)(fear ability)(small lightning)(large lightning)(slow ability)(resist magic +50)(resist electricity +100)(resist fear +100)",
116 "(speed +6)(item_power +6)[color=#FF15CD](armour +3)[/color]",
117 "(dam+3)(weapon speed 2)(Attacks: physical)",
118 "(Con+2)(item_power +1)",
119 "(Str+2)(Dex-1)(dam+3)(item_power +2)[color=#FF15CD](armour +5)[/color]",
120 "(Str+2)(dam+3)(item_power +1)[color=#FF15CD](armour +5)[/color]",
121 "(Cha+1)(ac+1)(Spell regen penalty 4)[color=#FF15CD](armour +4)[/color](resist blindness +1)",
122 "(ac+5)(Max speed 0.70)(Spell regen penalty 30)[color=#FF15CD](armour +40)[/color]",
123 "(ac+1)(Max speed 1.20)",
124 "(ac+3)(Max speed 0.90)(Spell regen penalty 10)[color=#FF15CD](armour +20)[/color]",
125 "(Cha-5)(ac+7)(item_power +10)(reflect spells)(reflect missiles)[color=#FF15CD](armour +15)[/color][color=red](resist fire +30)[/color][ul](resist drain +100)[/ul](resist ghosthit +80)",
126 "(ac+4)(item_power +6)[color=#FF15CD](armour +10)[/color][ul](resist drain +100)[/ul](resist ghosthit +50)",
132 static const char *treasures[] = {
147 static const char *treasure_results[] = {
149 "(wc+1)(dam+2)(Attacks: physical)",
151 "(dam+6)(weapon speed 9)(Attacks: physical)",
153 "(Con+2)(Cha-1)(dam+10)(item_power +15)(weapon speed 5)(regeneration+1)(Attacks: weaponmagic)[ul](resist drain +100)[/ul][color=green](resist poison +30)[/color]",
156 "(Str+1)(dam+9)(item_power +20)(weapon speed 6)(regeneration+1)(Attacks: electricity, drain)[color=#930C76](resist magic +30)[/color][color=blue](resist electricity +30)[/color][ul](resist drain +100)[/ul]",
158 "(Str+1)[color=#FF15CD](armour +5)[/color]",
165 fail_unless(test != NULL,
"couldn't create arch %s", archs[
check]);
175 fail_unless(strcmp(
buf, arch_results[
check]) == 0,
"describe_item(%s) returned \"%s\" instead of \"%s\"", archs[
check],
buf, arch_results[
check]);
185 fail_unless(
list != NULL,
"couldn't find treasure list %s", treasures[
check]);
187 fail_if(test == NULL,
"couldn't create item from treasure list %s", treasures[
check]);
197 fail_unless(strcmp(
buf, treasure_results[
check]) == 0,
"describe_item(treasure %s) returned \"%s\" instead of \"%s\" for item %s", treasures[
check],
buf, treasure_results[
check], test->
arch->
name);
206 #define DESCRIBE_PATH_SAFE(retbuf, variable, name, len, maxlen) \
209 safe_strcat(retbuf, "(" name ": ", len, maxlen); \
210 for (i = 0; i < NRSPELLPATHS; i++) \
211 if (variable&(1<<i)) { \
213 safe_strcat(retbuf, ", ", len, maxlen); \
216 safe_strcat(retbuf, spellpathnames[i], len, maxlen); \
218 safe_strcat(retbuf, ")", len, maxlen); \
221 #define DESCRIBE_ABILITY_SAFE(retbuf, variable, name, len, maxlen) \
224 safe_strcat(retbuf, "(" name ": ", len, maxlen); \
225 for (i = 0; i < NROFATTACKS; i++) \
226 if (variable&(1<<i)) { \
228 safe_strcat(retbuf, ", ", len, maxlen); \
231 safe_strcat(retbuf, attacks[i], len, maxlen); \
233 safe_strcat(retbuf, ")", len, maxlen); \
247 switch ((
int)((
FABS(
op->speed))*15)) {
249 snprintf(retbuf, size,
"(very slow movement)");
253 snprintf(retbuf, size,
"(slow movement)");
257 snprintf(retbuf, size,
"(normal movement)");
262 snprintf(retbuf, size,
"(fast movement)");
267 snprintf(retbuf, size,
"(very fast movement)");
274 snprintf(retbuf, size,
"(extremely fast movement)");
278 snprintf(retbuf, size,
"(lightning fast movement)");
283 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(undead)");
285 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(see invisible)");
287 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wield weapon)");
289 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(archer)");
291 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wear armour)");
293 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(wear ring)");
295 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(read scroll)");
297 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(fires wand/rod/horn)");
299 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(skill user)");
301 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(spellcaster)");
303 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(friendly)");
305 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(unaggressive)");
307 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(hitback)");
309 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(stealthy)");
310 if (
op->randomitems != NULL) {
314 for (
t =
op->randomitems->items;
t != NULL;
t =
t->next)
315 if (
t->item && (
t->item->clone.type ==
SPELL)) {
318 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(Spell abilities:)");
320 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(%s)",
t->item->clone.name);
324 if (
op->contr->digestion) {
325 if (
op->contr->digestion != 0)
326 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(sustenance%+d)",
op->contr->digestion);
328 if (
op->contr->gen_grace) {
329 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(grace%+d)",
op->contr->gen_grace);
331 if (
op->contr->gen_sp) {
332 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(magic%+d)",
op->contr->gen_sp);
334 if (
op->contr->gen_hp) {
335 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(regeneration%+d)",
op->contr->gen_hp);
337 if (
op->stats.luck) {
338 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(luck%+d)",
op->stats.luck);
343 len = strlen(retbuf);
352 if (
tmp &&
tmp->attacktype != 0) {
365 snprintf(retbuf+strlen(retbuf), size-strlen(retbuf),
"(%s %+d)",
resist_plus[i],
op->resist[i]);
376 memset(&
pl, 0,
sizeof(
pl));
388 fail_unless(strcmp(
buf, compat) == 0,
"(compat) description change:\n%s\n === vs ===\n%s",
buf, compat);
393 fail_unless(strcmp(
buf,
final) == 0,
"description change: \"%s\" vs \"%s\"",
buf,
final);
401 Suite *s = suite_create(
"item");
402 TCase *tc_core = tcase_create(
"Core");
407 suite_add_tcase(s, tc_core);
408 tcase_add_test(tc_core, test_describe_item);
409 tcase_add_test(tc_core, test_describe_monster_rewrite);
423 printf(
"Skipping item test - need glibc to get same results to check against\n");
428 SRunner *sr = srunner_create(s);
431 srunner_set_fork_status(sr, CK_NOFORK);
433 srunner_set_xml(sr, LOGDIR
"/unit/common/item.xml");
434 srunner_set_log(sr, LOGDIR
"/unit/common/item.out");
435 srunner_run_all(sr, CK_ENV);
436 nf = srunner_ntests_failed(sr);
438 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;