From 575a67b2a142b3f280805815ecd3b9f7fbcbee28 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 26 Aug 2018 15:06:08 +0900 Subject: [PATCH] mat4 test case fixes. The tests cases themselves were buggy. --- libs/util/test/test-mat4.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/libs/util/test/test-mat4.c b/libs/util/test/test-mat4.c index 623444a0d..1bd7afcc9 100644 --- a/libs/util/test/test-mat4.c +++ b/libs/util/test/test-mat4.c @@ -58,8 +58,8 @@ static vec3_t test_scales[] = { { 3, 1, 2}, { 3, 2, 1}, }; -#define num_translation_tests \ - (sizeof (test_translations) / sizeof (test_translations[0])) +#define num_scale_tests \ + (sizeof (test_scales) / sizeof (test_scales[0])) // return true if a and b are close enough (yay, floats) static int @@ -143,7 +143,8 @@ test_transform2 (const vec3_t angles, const vec3_t scale, vec3_t x, y; quat_t rotation; mat4_t mat; - vec3_t rot, sc, sh, tr; + quat_t rot; + vec3_t sc, sh, tr; VectorCopy (v, x); AngleQuat (angles, rotation); @@ -171,6 +172,9 @@ fail: VectorExpand (translation), VectorExpand (v)); printf (" (%g %g %g)\n", VectorExpand (x)); printf (" (%g %g %g)\n", VectorExpand (y)); + printf (" (%g %g %g %g) (%g %g %g %g) (%g %g %g) (%g %g %g) (%g %g %g)\n", + QuatExpand (rotation), QuatExpand (rot), VectorExpand (sh), + VectorExpand (sc), VectorExpand (tr)); return 0; } @@ -214,33 +218,41 @@ main (int argc, const char **argv) size_t i, j, k; for (i = 0; i < num_angle_tests; i ++) { - if (!test_angle (test_angles[i])) + if (!test_angle (test_angles[i])) { res = 1; + printf("angle test %zd failed\n", i); + } } for (i = 0; i < num_angle_tests; i ++) { - for (j = 0; j < num_translation_tests; j ++) { + for (j = 0; j < num_scale_tests; j ++) { for (k = 0; k < num_translation_tests; k ++) { if (!test_transform (test_angles[i], test_scales[j], - test_translations[k])) + test_translations[k])) { res = 1; + printf("transform test %zd:%zd:%zd failed\n", i, j, k); + } } } } for (i = 0; i < num_angle_tests; i ++) { - for (j = 0; j < num_translation_tests; j ++) { + for (j = 0; j < num_scale_tests; j ++) { for (k = 0; k < num_translation_tests; k ++) { if (!test_transform2 (test_angles[i], test_scales[j], - test_translations[k])) + test_translations[k])) { res = 1; + printf("transform2 test %zd:%zd:%zd failed\n", i, j, k); + } } } } for (i = 0; i < num_angle_tests; i ++) { - for (j = 0; j < num_translation_tests; j ++) { + for (j = 0; j < num_scale_tests; j ++) { for (k = 0; k < num_translation_tests; k ++) { if (!test_inverse (test_angles[i], test_scales[j], - test_translations[k])) + test_translations[k])) { res = 1; + printf("inverse test %zd:%zd:%zd failed\n", i, j, k); + } } } }