From 25e693cc46324b4ec588530de542bba8af6f47c6 Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 21:11:11 +0100 Subject: style: add vertical compression rules to clang-format - Enabled AllowShortFunctionsOnASingleLine: All - Enabled AllowShortBlocksOnASingleLine: Always - Enabled AllowShortIfStatementsOnASingleLine: Always - Enabled AllowShortLoopsOnASingleLine: true - Set MaxEmptyLinesToKeep: 1 - Applied formatting to all source files. --- src/tests/test_maths.cc | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/tests/test_maths.cc') 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 // 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 void test_vector_ops(int n) { @@ -24,19 +22,16 @@ template 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 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 -- cgit v1.2.3