Fix test to properly check that we're "close enough" and remove _equiv (use Catch's Approx instead)

This commit is contained in:
Joseph Lenox 2018-07-27 19:50:20 -05:00
parent 1ea86dcb5d
commit c94a168a5e
2 changed files with 5 additions and 5 deletions

View File

@ -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<double>(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
}

View File

@ -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 <typename T, typename U>
bool _equiv(const T& a, const U& b) { return abs(a - b) < Slic3r::Geometry::epsilon; }
template <typename T>
bool _equiv(const T& a, const T& b) { return abs(a - b) < Slic3r::Geometry::epsilon; }
template <typename T, typename U>
bool _equiv(const T& a, const U& b, double epsilon) { return abs(a - b) < epsilon; }
template <typename T>
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);