From c94a168a5e8114eea9ce28348bb386a593adb8d1 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Fri, 27 Jul 2018 19:50:20 -0500 Subject: [PATCH] Fix test to properly check that we're "close enough" and remove _equiv (use Catch's Approx instead) --- src/test/libslic3r/test_flow.cpp | 2 +- src/test/test_data.hpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/libslic3r/test_flow.cpp b/src/test/libslic3r/test_flow.cpp index f8bd929b6..0f95e1cf8 100644 --- a/src/test/libslic3r/test_flow.cpp +++ b/src/test/libslic3r/test_flow.cpp @@ -47,7 +47,7 @@ SCENARIO("Extrusion width specifics", "[!mayfail]") { bool pass = false; auto avg_E {std::accumulate(E_per_mm_bottom.cbegin(), E_per_mm_bottom.cend(), 0.0) / static_cast(E_per_mm_bottom.size())}; - pass = std::count_if(E_per_mm_bottom.cbegin(), E_per_mm_bottom.cend(), [avg_E] (double v) { return _equiv(v, avg_E, 0.015); }) == 0; + pass = (std::count_if(E_per_mm_bottom.cbegin(), E_per_mm_bottom.cend(), [avg_E] (const double& v) { return v == Approx(avg_E); }) == 0); REQUIRE(pass == true); REQUIRE(E_per_mm_bottom.size() > 0); // make sure it actually passed because of extrusion } diff --git a/src/test/test_data.hpp b/src/test/test_data.hpp index e5ea24e93..20a4b90ef 100644 --- a/src/test/test_data.hpp +++ b/src/test/test_data.hpp @@ -51,11 +51,11 @@ TriangleMesh mesh(TestMesh m, Pointf3 translate, Pointf3 scale = Pointf3(1.0, 1. TriangleMesh mesh(TestMesh m, Pointf3 translate, double scale = 1.0); /// Templated function to see if two values are equivalent (+/- epsilon) -template -bool _equiv(const T& a, const U& b) { return abs(a - b) < Slic3r::Geometry::epsilon; } +template +bool _equiv(const T& a, const T& b) { return abs(a - b) < Slic3r::Geometry::epsilon; } -template -bool _equiv(const T& a, const U& b, double epsilon) { return abs(a - b) < epsilon; } +template +bool _equiv(const T& a, const T& b, double epsilon) { return abs(a - b) < epsilon; } //Slic3r::Model model(const std::string& model_name, TestMesh m, Pointf3 translate = Pointf3(0,0,0), Pointf3 scale = Pointf3(1.0,1.0,1.0)); //Slic3r::Model model(const std::string& model_name, TestMesh m, Pointf3 translate = Pointf3(0,0,0), double scale = 1.0);