From b45e9d2830817d5b576f3c5683340875cf360d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0ach?= Date: Thu, 19 Oct 2023 15:42:24 +0200 Subject: [PATCH] Fix: Give more space for a rounding error to a supports spots generator test. There was a test that relied on randomness and also checked the result with very hight precision. That led to a failed test once upon a time. Now the checking is more benevolent (it should be, as the code is not expected to be precise) and also the randomness is removed. --- tests/libslic3r/test_support_spots_generator.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/libslic3r/test_support_spots_generator.cpp b/tests/libslic3r/test_support_spots_generator.cpp index d7b2f4611c..0cd8c51f8e 100644 --- a/tests/libslic3r/test_support_spots_generator.cpp +++ b/tests/libslic3r/test_support_spots_generator.cpp @@ -71,11 +71,8 @@ TEST_CASE("Moments calculation for rotated axis.", "[SupportSpotsGenerator]") { Integrals integrals{{polygon}}; - std::mt19937 generator{std::random_device{}()}; - std::uniform_real_distribution angle_distribution{0.f, float(2*M_PI)}; - // Meassured counterclockwise from (1, 0) - const float angle = angle_distribution(generator); + const float angle = 1.432f; Vec2f axis{std::cos(angle), std::sin(angle)}; float moment_calculated_then_rotated = compute_second_moment( @@ -93,7 +90,8 @@ TEST_CASE("Moments calculation for rotated axis.", "[SupportSpotsGenerator]") { Vec2f{1, 0} ); - CHECK(moment_calculated_then_rotated == Approx(moment_rotated_polygon)); + // Up to 0.1% accuracy + CHECK_THAT(moment_calculated_then_rotated, Catch::Matchers::WithinRel(moment_rotated_polygon, 0.001f)); } struct ObjectPartFixture {