summaryrefslogtreecommitdiff
path: root/src/tests/common/test_math_helpers.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-14 02:39:49 +0100
committerskal <pascal.massimino@gmail.com>2026-02-14 02:39:49 +0100
commit8dd77545b5ec2f45ce46b98dd7d94a3c4a13e290 (patch)
treea338b9c1356da64a609621155c81d8d96f7ca7fe /src/tests/common/test_math_helpers.h
parentc007d7fa6ddb1936108aeca156b2a4bda425ca84 (diff)
Factor common test patterns into reusable utilitiesHEADmain
Refactor duplicated test setup/teardown code into shared fixtures: - test_math_helpers.h: Float comparison (test_near, test_near_vec3) - AudioTestFixture: RAII wrapper for AudioEngine lifecycle - EffectTestFixture: Combined WebGPU + AudioEngine + MainSequence Migrated 9 test files (3 math, 6 audio) to use fixtures. Net reduction: 54 LOC (178 insertions, 232 deletions). All 34 tests passing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests/common/test_math_helpers.h')
-rw-r--r--src/tests/common/test_math_helpers.h18
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);
+}