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)(Attacks: physical)",
103 "(Int+2)(Pow+2)(ac+2)(item_power +5)(magic+1)(armour +5)",
104 "(Str+1)(Wis+2)(Cha+2)(dam+15)(item_power +25)(weapon speed 6)(Attacks: weaponmagic, blinding)(resist magic +30)(resist drain +100)",
105 "(dam+8)(weapon speed 8)(Attacks: physical)",
108 "(food+100)(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:)(burning hands ability)(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)(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)(armour +3)",
117 "(dam+3)(weapon speed 2)(Attacks: physical)",
118 "(Con+2)(item_power +1)",
119 "(Str+2)(Dex-1)(dam+3)(item_power +2)(armour +3)",
120 "(Str+2)(dam+3)(item_power +1)(armour +3)",
121 "(Cha+1)(ac+1)(Spell regen penalty 4)(armour +4)(resist blindness +1)",
122 "(ac+5)(Max speed 0.70)(Spell regen penalty 30)(armour +40)",
123 "(ac+1)(Max speed 1.20)",
124 "(ac+3)(Max speed 0.90)(Spell regen penalty 10)(armour +20)",
125 "(Cha-5)(ac+7)(item_power +10)(reflect spells)(reflect missiles)(armour +15)(resist fire +30)(resist drain +100)(resist ghosthit +80)",
126 "(ac+4)(item_power +6)(armour +10)(resist drain +100)(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)(resist drain +100)(resist poison +30)",
156 "(Str+1)(dam+9)(item_power +20)(weapon speed 6)(regeneration+1)(Attacks: electricity, drain)(resist magic +30)(resist electricity +30)(resist drain +100)",
158 "(Str+1)(armour +3)",
163 for (check = 0; archs[check] != NULL; check++) {
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]);
182 for (check = 0; treasures[check] != NULL; check++) {
184 fail_unless(list != NULL,
"couldn't find treasure list %s", treasures[check]);
186 fail_if(test == NULL,
"couldn't create item from treasure list %s", treasures[check]);
196 fail_unless(strcmp(buf, treasure_results[check]) == 0,
"describe_item(treasure %s) returned \"%s\" instead of \"%s\"", treasures[check], buf, treasure_results[check]);
205 Suite *s = suite_create(
"item");
206 TCase *tc_core = tcase_create(
"Core");
211 suite_add_tcase(s, tc_core);
212 tcase_add_test(tc_core, test_describe_item);
220 SRunner *sr = srunner_create(s);
222 srunner_set_xml(sr, LOGDIR
"/unit/common/item.xml");
223 srunner_set_log(sr, LOGDIR
"/unit/common/item.out");
224 srunner_run_all(sr, CK_ENV);
225 nf = srunner_ntests_failed(sr);
227 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
treasurelist * find_treasurelist(const char *name)
END_TEST Suite * item_suite(void)
START_TEST(test_describe_item)
void describe_item(const object *op, const object *owner, char *retbuf, size_t size)
object * generate_treasure(treasurelist *t, int difficulty)
void free_object(object *ob)