48 object *tmp, *best = NULL;
49 int match_val = 0, tmpmatch;
51 for (tmp = start; tmp; tmp = tmp->
below) {
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");
106 fail_unless(
GET_MAP_OB(test_map, 0, 0) == sack);
112 fail_unless(
GET_MAP_OB(test_map, 1, 0) == obj,
"object was removed from map?");
113 fail_unless(sack->
inv == NULL,
"sack's inventory isn't null?");
121 fail_unless(sack->
type ==
CONTAINER,
"sack isn't a container?");
123 fail_unless(
GET_MAP_OB(test_map, 0, 0) == sack,
"sack not put on map?");
127 fail_unless(sack->
inv == obj,
"object not inserted into sack?");
128 fail_unless(
GET_MAP_OB(test_map, 1, 0) == NULL,
"object wasn't removed from map?");
136 fail_unless(sack->
inv == NULL,
"item was put in sack even if too heavy?");
137 fail_unless(
GET_MAP_OB(test_map, 1, 0) == obj,
"object was removed from map?");
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?");
175 Suite *s = suite_create(
"c_object");
176 TCase *tc_core = tcase_create(
"Core");
181 suite_add_tcase(s, tc_core);
182 tcase_add_test(tc_core, test_find_best_apply_object_match);
183 tcase_add_test(tc_core, test_put_object_in_sack);
191 SRunner *sr = srunner_create(s);
199 srunner_set_xml(sr, LOGDIR
"/unit/server/c_object.xml");
200 srunner_set_log(sr, LOGDIR
"/unit/server/c_object.out");
201 srunner_run_all(sr, CK_ENV);
202 nf = srunner_ntests_failed(sr);
204 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
END_TEST Suite * c_object_suite(void)
mapstruct * get_empty_map(int sizex, int sizey)
object * insert_ob_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
int item_matched_string(object *pl, object *op, const char *name)
void free_map(mapstruct *m)
void remove_ob(object *op)
object * create_archetype(const char *name)
START_TEST(test_find_best_apply_object_match)
void init(int argc, char **argv)
#define QUERY_FLAG(xyz, p)
#define CLEAR_FLAG(xyz, p)
object * insert_ob_in_ob(object *op, object *where)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32 nrof)
sstring add_string(const char *str)
#define GET_MAP_OB(M, X, Y)
void free_object(object *ob)
static object * find_best_apply_object_match(object *start, object *pl, const char *params, int aflag)