47 object *
first, *second, *third, *owner, *
found;
53 memset(&
pl, 0,
sizeof(
pl));
54 memset(&sock, 0,
sizeof(sock));
63 for (uint8_t i = 0; i < 200; i++) {
69 for (uint8_t i = 0; i < 200; i++) {
78 for (uint8_t i = 0; i < 200; i++) {
80 fail_if(
found == owner,
"Found owner?");
81 fail_unless(
found == second,
"Should find second!");
84 second->
owner = owner;
86 for (uint8_t i = 0; i < 200; i++) {
88 fail_if(
found == owner,
"Found owner?");
89 fail_unless(
found == NULL,
"Shouldn't find anything since both are pets");
93 for (uint8_t i = 0; i < 200; i++) {
95 fail_unless(
found == NULL,
"Pets shouldn't attack other pets");
100 for (uint8_t i = 0; i < 200; i++) {
102 fail_unless(
found == third,
"Should find third monster");
105 uint8_t co = 0, cs = 0, ct = 0;
106 for (uint16_t i = 0; i < 2000; i++) {
108 fail_unless(
found,
"Should find a target!");
109 if (
found == owner) {
111 }
else if (
found == second) {
117 fail_unless(co != 0,
"Should have found the owner");
118 fail_unless(cs != 0,
"Should have found second");
119 fail_unless(ct != 0,
"Should have found third");
124 Suite *s = suite_create(
"monster");
125 TCase *tc_core = tcase_create(
"Core");
130 suite_add_tcase(s, tc_core);
131 tcase_add_test(tc_core, test_monster_find_nearest_enemy);
143 SRunner *sr = srunner_create(s);
148 srunner_set_xml(sr, LOGDIR
"/unit/server/monster.xml");
149 srunner_set_log(sr, LOGDIR
"/unit/server/monster.out");
150 srunner_run_all(sr, CK_ENV);
151 nf = srunner_ntests_failed(sr);
153 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;