diff options
Diffstat (limited to 'src/tests/common/test_math_helpers.h')
| -rw-r--r-- | src/tests/common/test_math_helpers.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tests/common/test_math_helpers.h b/src/tests/common/test_math_helpers.h new file mode 100644 index 0000000..99e7f9d --- /dev/null +++ b/src/tests/common/test_math_helpers.h @@ -0,0 +1,18 @@ +// test_math_helpers.h - Math utilities for test code +// Common floating-point comparison helpers + +#pragma once +#include <cmath> +#include "util/mini_math.h" + +// Floating-point comparison with epsilon tolerance +inline bool test_near(float a, float b, float epsilon = 1e-6f) { + return fabs(a - b) < epsilon; +} + +// Vector comparison +inline bool test_near_vec3(vec3 a, vec3 b, float epsilon = 1e-6f) { + return test_near(a.x, b.x, epsilon) && + test_near(a.y, b.y, epsilon) && + test_near(a.z, b.z, epsilon); +} |
