diff options
| author | skal <pascal.massimino@gmail.com> | 2026-01-31 21:11:11 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-01-31 21:11:11 +0100 |
| commit | 25e693cc46324b4ec588530de542bba8af6f47c6 (patch) | |
| tree | 8a959e442f9330dd3f881fe4109e83b831f25a7e /src/tests/test_maths.cc | |
| parent | 9379697ccdf6f44ade7933d5635f72f644f6b92e (diff) | |
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.
Diffstat (limited to 'src/tests/test_maths.cc')
| -rw-r--r-- | src/tests/test_maths.cc | 19 |
1 files changed, 6 insertions, 13 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 |
