diff options
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 53 |
1 files changed, 31 insertions, 22 deletions
@@ -63,37 +63,46 @@ int main(int argc, char *argv[]) return 1; } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { - objects[i].ix = ix2_object_new(ix2, NULL, NULL, &objects[i].aabb, &objects[i]); - if (!o) { - fprintf(stderr, "unable to insert object %i\n", i); - return 1; + for (int n = 0; n < 20; n++) { + for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { + objects[i].ix = ix2_object_new(ix2, NULL, NULL, &objects[i].aabb, &objects[i]); + if (!objects[i].ix) { + fprintf(stderr, "unable to insert object %i\n", i); + return 1; + } } - } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { - /* TODO: actually verify the expected objects are hit */ - if (!ix2_search_by_point(ix2, &objects[i].aabb.min, cb, &objects[i])) { - fprintf(stderr, "unable to lookup object %i by min point\n", i); - return 1; + for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { + /* TODO: actually verify the expected objects are hit */ + if (!ix2_search_by_point(ix2, &objects[i].aabb.min, cb, &objects[i])) { + fprintf(stderr, "unable to lookup object %i by min point\n", i); + return 1; + } + + if (!ix2_search_by_point(ix2, &objects[i].aabb.max, cb, &objects[i])) { + fprintf(stderr, "unable to lookup object %i by max point\n", i); + return 1; + } } - if (!ix2_search_by_point(ix2, &objects[i].aabb.max, cb, &objects[i])) { - fprintf(stderr, "unable to lookup object %i by max point\n", i); - return 1; + for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { + /* TODO: actually verify the expected objects are hit */ + if (!ix2_search_by_aabb(ix2, NULL, NULL, &objects[i].aabb, cb, &objects[i])) { + fprintf(stderr, "unable to lookup object %i by perfect aabb\n", i); + return 1; + } } - } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { - /* TODO: actually verify the expected objects are hit */ - if (!ix2_search_by_aabb(ix2, NULL, NULL, &objects[i].aabb, cb, &objects[i])) { - fprintf(stderr, "unable to lookup object %i by perfect aabb\n", i); - return 1; + if (n % 2) { + fprintf(stderr, "explicitly freeing all objects\n"); + for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) + ix2_object_free(ix2, objects[i].ix); + } else { + fprintf(stderr, "resetting\n"); + ix2_reset(ix2); } } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) - ix2_object_free(ix2, objects[i].ix); ix2_free(ix2); |