summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_maths.cc19
-rw-r--r--src/tests/test_sequence.cc16
2 files changed, 10 insertions, 25 deletions
diff --git a/src/tests/test_maths.cc b/src/tests/test_maths.cc
index d9bc4d1..e7a686c 100644
--- a/src/tests/test_maths.cc
+++ b/src/tests/test_maths.cc
@@ -9,9 +9,7 @@
#include <vector>
// Checks if two floats are approximately equal
-bool near(float a, float b, float e = 0.001f) {
- return std::abs(a - b) < e;
-}
+bool near(float a, float b, float e = 0.001f) { return std::abs(a - b) < e; }
// Generic test runner for any vector type (vec2, vec3, vec4)
template <typename T> void test_vector_ops(int n) {
@@ -24,19 +22,16 @@ template <typename T> void test_vector_ops(int n) {
// Add
T c = a + b;
- for (int i = 0; i < n; ++i)
- assert(near(c[i], (float)(i + 1) + 10.0f));
+ for (int i = 0; i < n; ++i) assert(near(c[i], (float)(i + 1) + 10.0f));
// Scale
T s = a * 2.0f;
- for (int i = 0; i < n; ++i)
- assert(near(s[i], (float)(i + 1) * 2.0f));
+ for (int i = 0; i < n; ++i) assert(near(s[i], (float)(i + 1) * 2.0f));
// Dot Product
// vec3(1,2,3) . vec3(1,2,3) = 1+4+9 = 14
float expected_dot = 0;
- for (int i = 0; i < n; ++i)
- expected_dot += a[i] * a[i];
+ for (int i = 0; i < n; ++i) expected_dot += a[i] * a[i];
assert(near(T::dot(a, a), expected_dot));
// Norm (Length)
@@ -48,8 +43,7 @@ template <typename T> void test_vector_ops(int n) {
// Lerp
T l = lerp(a, b, 0.3f);
- for (int i = 0; i < n; ++i)
- assert(near(l[i], .7 * (i + 1) + .3 * 10.0f));
+ for (int i = 0; i < n; ++i) assert(near(l[i], .7 * (i + 1) + .3 * 10.0f));
}
// Specific test for padding alignment in vec3
@@ -133,8 +127,7 @@ void test_spring() {
std::cout << "Testing Spring..." << std::endl;
float p = 0, v = 0;
// Simulate approx 1 sec with 0.5s smooth time
- for (int i = 0; i < 60; ++i)
- spring::solve(p, v, 10.0f, 0.5f, 0.016f);
+ for (int i = 0; i < 60; ++i) spring::solve(p, v, 10.0f, 0.5f, 0.016f);
assert(p > 8.5f);
// Test vector spring
diff --git a/src/tests/test_sequence.cc b/src/tests/test_sequence.cc
index db66b8a..363846b 100644
--- a/src/tests/test_sequence.cc
+++ b/src/tests/test_sequence.cc
@@ -26,16 +26,13 @@ public:
int end_calls = 0;
bool is_pp = false;
- DummyEffect(bool post_process = false) : is_pp(post_process) {
- }
+ DummyEffect(bool post_process = false) : is_pp(post_process) {}
void init(MainSequence *demo) override {
init_calls++;
(void)demo;
}
- void start() override {
- start_calls++;
- }
+ void start() override { start_calls++; }
void render(WGPURenderPassEncoder pass, float time, float beat,
float intensity, float aspect_ratio) override {
render_calls++;
@@ -53,12 +50,8 @@ public:
(void)intensity;
(void)aspect_ratio;
}
- void end() override {
- end_calls++;
- }
- bool is_post_process() const override {
- return is_pp;
- }
+ void end() override { end_calls++; }
+ bool is_post_process() const override { return is_pp; }
};
// --- Dummy PostProcessEffect for Tracking (unused in simplified tests) ---
@@ -169,7 +162,6 @@ void test_simulate_until() {
}
int main() {
-
printf("Running Sequence/Effect System tests...\n");
// TODO: Re-enable and fix test_effect_lifecycle once GPU resource mocking is