| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#include <stdlib.h> |
| 30 |
#include <check.h> |
| 31 |
#include <global.h> |
| 32 |
#include <sproto.h> |
| 33 |
|
| 34 |
static void setup(void) { |
| 35 |
} |
| 36 |
|
| 37 |
static void teardown(void) { |
| 38 |
} |
| 39 |
|
| 40 |
START_TEST(test_insert) { |
| 41 |
mapstruct *map1; |
| 42 |
archetype *big_galleon_arch; |
| 43 |
object *big_galleon; |
| 44 |
object *ob; |
| 45 |
|
| 46 |
map1 = ready_map_name("/world/world_103_128", 0); |
| 47 |
fail_unless(map1 != NULL, "cannot load map /world/world_103_128"); |
| 48 |
|
| 49 |
big_galleon_arch = find_archetype("big_galleon"); |
| 50 |
fail_unless(big_galleon_arch != NULL, "cannot find archetype big_galleon"); |
| 51 |
big_galleon = object_create_arch(big_galleon_arch); |
| 52 |
fail_unless(big_galleon != NULL, "cannot create object big_galleon"); |
| 53 |
|
| 54 |
for (ob = big_galleon; ob != NULL; ob = ob->more) |
| 55 |
if (ob->arch->clone.x > 0) |
| 56 |
break; |
| 57 |
fail_unless(ob != NULL, "big_galleon's height must be at least two"); |
| 58 |
object_insert_in_map_at(big_galleon, map1, NULL, 0, map1->width/2, map1->height-1); |
| 59 |
for (ob = big_galleon; ob != NULL; ob = ob->more) |
| 60 |
fail_unless(ob->map != NULL); |
| 61 |
} |
| 62 |
END_TEST |
| 63 |
|
| 64 |
static Suite *bug_suite(void) { |
| 65 |
Suite *s = suite_create("bug"); |
| 66 |
TCase *tc_core = tcase_create("Core"); |
| 67 |
|
| 68 |
tcase_add_checked_fixture(tc_core, setup, teardown); |
| 69 |
|
| 70 |
suite_add_tcase(s, tc_core); |
| 71 |
tcase_add_test(tc_core, test_insert); |
| 72 |
tcase_set_timeout(tc_core, 0); |
| 73 |
|
| 74 |
return s; |
| 75 |
} |
| 76 |
|
| 77 |
int main(void) { |
| 78 |
int nf; |
| 79 |
Suite *s = bug_suite(); |
| 80 |
SRunner *sr = srunner_create(s); |
| 81 |
|
| 82 |
srunner_set_fork_status(sr, CK_NOFORK); |
| 83 |
init(0, NULL); |
| 84 |
|
| 85 |
srunner_set_xml(sr, LOGDIR "/bugs/bugtrack/2879249.xml"); |
| 86 |
srunner_set_log(sr, LOGDIR "/bugs/bugtrack/2879249.out"); |
| 87 |
srunner_run_all(sr, CK_ENV); |
| 88 |
nf = srunner_ntests_failed(sr); |
| 89 |
srunner_free(sr); |
| 90 |
return nf == 0 ? EXIT_SUCCESS : EXIT_FAILURE; |
| 91 |
} |