From 26aab6ecf22cac036821a9b24efe57733a980fbb Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 29 Jul 2025 16:12:28 +0200 Subject: [PATCH] Fix flakey matrix rotation unit test for now --- src/unittest/test_irr_matrix4.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/unittest/test_irr_matrix4.cpp b/src/unittest/test_irr_matrix4.cpp index 9deda5811..823166636 100644 --- a/src/unittest/test_irr_matrix4.cpp +++ b/src/unittest/test_irr_matrix4.cpp @@ -11,8 +11,8 @@ using matrix4 = core::matrix4; -static bool matrix_equals(const matrix4 &a, const matrix4 &b) { - return a.equals(b, 0.00001f); +static bool matrix_equals(const matrix4 &a, const matrix4 &b, f32 tolerance = 0.00001f) { + return a.equals(b, tolerance); } constexpr v3f x{1, 0, 0}; @@ -121,18 +121,20 @@ SECTION("getRotationRadians") { v3f rot = (R * S).getRotationRadians(); matrix4 B; B.setRotationRadians(rot); - CHECK(matrix_equals(R, B)); + // TODO we would like to use a lower tolerance here, but that makes the test likely to fail. + f32 tol = 0.001f; + CHECK(matrix_equals(R, B, tol)); }; SECTION("returns a rotation equivalent to the original rotation") { test_rotation_degrees({1.0f, 2.0f, 3.0f}, v3f(1)); Catch::Generators::RandomFloatingGenerator gen_angle(0.0f, 2 * core::PI, Catch::getSeed()); Catch::Generators::RandomFloatingGenerator gen_scale(0.1f, 10, Catch::getSeed()); - auto draw = [](auto gen) { + auto draw = [](auto &gen) { f32 f = gen.get(); gen.next(); return f; }; - auto draw_v3f = [&](auto gen) { + auto draw_v3f = [&](auto &gen) { return v3f{draw(gen), draw(gen), draw(gen)}; }; for (int i = 0; i < 1000; ++i)