47 object *first, *second, *third, *owner, *
found;
52 memset(&
pl, 0,
sizeof(
pl));
60 for (uint8_t i = 0; i < 200; i++) {
66 for (uint8_t i = 0; i < 200; i++) {
75 for (uint8_t i = 0; i < 200; i++) {
77 fail_if(
found == owner,
"Found owner?");
78 fail_unless(
found == second,
"Should find second!");
81 second->
owner = owner;
83 for (uint8_t i = 0; i < 200; i++) {
85 fail_if(
found == owner,
"Found owner?");
86 fail_unless(
found == NULL,
"Shouldn't find anything since both are pets");
90 for (uint8_t i = 0; i < 200; i++) {
92 fail_unless(
found == NULL,
"Pets shouldn't attack other pets");
97 for (uint8_t i = 0; i < 200; i++) {
99 fail_unless(
found == third,
"Should find third monster");
102 uint8_t co = 0, cs = 0, ct = 0;
103 for (uint16_t i = 0; i < 2000; i++) {
105 fail_unless(
found,
"Should find a target!");
106 if (
found == owner) {
108 }
else if (
found == second) {
114 fail_unless(co != 0,
"Should have found the owner");
115 fail_unless(cs != 0,
"Should have found second");
116 fail_unless(ct != 0,
"Should have found third");
121 Suite *s = suite_create(
"monster");
122 TCase *tc_core = tcase_create(
"Core");
127 suite_add_tcase(s, tc_core);
128 tcase_add_test(tc_core, test_monster_find_nearest_enemy);
140 SRunner *sr = srunner_create(s);
145 srunner_set_xml(sr, LOGDIR
"/unit/server/monster.xml");
146 srunner_set_log(sr, LOGDIR
"/unit/server/monster.out");
147 srunner_run_all(sr, CK_ENV);
148 nf = srunner_ntests_failed(sr);
150 return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;