48 object *
tmp, *best = NULL;
49 int match_val = 0, tmpmatch;
68 object *gorokh, *cloak, *other;
71 fail_unless(
pl != NULL,
"can't find kobold archetype.");
85 fail_unless(
found == other,
"not found gem but %s",
found ?
found->name :
"nothing");
88 fail_unless(
found == cloak,
"didn't find cloak but %s",
found ?
found->name :
"nothing");
91 fail_unless(
found == NULL,
"Gorokh found %s instead of nothing",
found ?
found->name :
"nothing??");
97 object *sack, *
obj, *sack2, *dummy;
102 fail_unless(
test_map != NULL,
"can't create test map");
113 fail_unless(sack->
inv == NULL,
"sack's inventory isn't null?");
121 fail_unless(sack->
type ==
CONTAINER,
"sack isn't a container?");
127 fail_unless(sack->
inv ==
obj,
"object not inserted into sack?");
136 fail_unless(sack->
inv == NULL,
"item was put in sack even if too heavy?");
144 fail_unless(sack->
nrof == 1,
"sack wasn't split?");
145 fail_unless(sack->
above != NULL,
"no new sack created?");
146 fail_unless(sack->
inv ==
obj,
"object not inserted in old sack?");
147 fail_unless(sack ==
obj->
env,
"object's env not updated?");
155 fail_unless(sack2->
inv == NULL,
"sack2's not empty?");
156 fail_unless(sack->
inv ==
obj,
"obj wasn't transferred?");
165 fail_unless(sack->
inv == NULL,
"sack wasn't put into sack2?");
166 fail_unless(sack2->
inv != NULL,
"sack2 wasn't filled?");
167 fail_unless(sack2->
above != NULL,
"sack2 wasn't split?");
168 fail_unless(sack2->
above->
inv == NULL,
"sack2's split was filled?");
174 #define TEST_ITEMS_COUNT 11
203 static void do_test(
const int do_what,
const char *param, ...) {
207 const char *
action = do_what ==
DO_TAKE ?
"picked" :
"dropped";
210 fail_unless(
test_map != NULL,
"couldn't create map");
212 fail_unless(monster != NULL,
"couldn't create kobold");
216 object *
top = monster;
219 fail_unless(
arch != NULL,
"couldn't find arch %s",
test_items[i]);
221 fail_unless(items[i] != NULL,
"couldn't create %s",
test_items[i]);
231 va_start(
args, param);
233 while ((idx = va_arg(
args,
int)) != -1) {
236 while ((idx = va_arg(
args,
int)) != -1) {
247 while ((idx = va_arg(
args,
int)) != -1) {
253 fail_unless(items[i]->
env == monster,
"%s wasn't %s up with %s!",
test_items[i],
action, param);
261 fail_unless(items[i]->
env == monster,
"%s was %s up with %s!",
test_items[i],
action, param);
281 do_test(
DO_TAKE,
"all", -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1);
282 do_test(
DO_TAKE,
"*", -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1);
319 Suite *s = suite_create(
"c_object");
320 TCase *tc_core = tcase_create(
"Core");
325 suite_add_tcase(s, tc_core);
326 tcase_add_test(tc_core, test_find_best_apply_object_match);
327 tcase_add_test(tc_core, test_put_object_in_sack);
328 tcase_add_test(tc_core, test_command_take);
329 tcase_add_test(tc_core, test_command_drop);
337 SRunner *sr = srunner_create(s);
343 srunner_set_fork_status (sr, CK_NOFORK);
345 srunner_set_xml(sr, LOGDIR
"/unit/server/c_object.xml");
346 srunner_set_log(sr, LOGDIR
"/unit/server/c_object.out");
347 srunner_run_all(sr, CK_ENV);
348 nf = srunner_ntests_failed(sr);
350 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;