diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-11-27 23:47:46 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-11-27 23:50:58 -0800 |
commit | 28c0347ab1af0adec0249788f8351b0bde06297e (patch) | |
tree | 74635d38ff8a4bf0022095391ea978ffc8c6d7bb /src/test.c | |
parent | b62ceffebf1e26d7cb8e9c1edb52020a803e6713 (diff) |
libix3: add ix3_reset()
This basically amounts to a pad_reset() wrapper.
Also incorporated resets into the test, while fixing a stupid
bug there.
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 54 |
1 files changed, 31 insertions, 23 deletions
@@ -63,38 +63,46 @@ int main(int argc, char *argv[]) return 1; } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) { - objects[i].ix = ix3_object_new(ix3, 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 = ix3_object_new(ix3, 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 (!ix3_search_by_point(ix3, &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 (!ix3_search_by_point(ix3, &objects[i].aabb.min, cb, &objects[i])) { + fprintf(stderr, "unable to lookup object %i by min point\n", i); + return 1; + } + + if (!ix3_search_by_point(ix3, &objects[i].aabb.max, cb, &objects[i])) { + fprintf(stderr, "unable to lookup object %i by max point\n", i); + return 1; + } } - if (!ix3_search_by_point(ix3, &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 (!ix3_search_by_aabb(ix3, 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 (!ix3_search_by_aabb(ix3, 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++) + ix3_object_free(ix3, objects[i].ix); + } else { + fprintf(stderr, "resetting\n"); + ix3_reset(ix3); } } - for (int i = 0; i < sizeof(objects) / sizeof(*objects); i++) - ix3_object_free(ix3, objects[i].ix); - ix3_free(ix3); return 0; |