diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b97967fe34..c5fe4a2407 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,26 +1,18 @@ -# TODO Add individual tests as executables in separate directories -# add_subirectory() +# Add individual tests as executables in separate directories at the bottom of this file + +add_subdirectory(catch2) set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data) file(TO_NATIVE_PATH "${TEST_DATA_DIR}" TEST_DATA_DIR) -add_library(Catch2 INTERFACE) -list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/Catch2) -target_include_directories(Catch2 INTERFACE ${CMAKE_CURRENT_LIST_DIR}) -add_library(Catch2::Catch2 ALIAS Catch2) -target_compile_definitions(Catch2 INTERFACE -DCATCH_CONFIG_ENABLE_BENCHMARKING) -if (APPLE) - # OSX builds targeting OSX 10.9 do not support new std::uncought_exception() - # see https://github.com/catchorg/Catch2/issues/1218 - target_compile_definitions(Catch2 INTERFACE -DCATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) -endif() +include(CTest) include(Catch) -set(CATCH_EXTRA_ARGS "" CACHE STRING "Extra arguments for catch2 test suites.") +set(CATCH_EXTRA_ARGS "" CACHE STRING "Extra arguments for catch2 test suites.") # Unknown if this still works and/or should be replaced with something else. add_library(test_common INTERFACE) target_compile_definitions(test_common INTERFACE TEST_DATA_DIR=R"\(${TEST_DATA_DIR}\)" CATCH_CONFIG_FAST_COMPILE) -target_link_libraries(test_common INTERFACE Catch2::Catch2) +target_include_directories(test_common INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) if (APPLE) target_link_libraries(test_common INTERFACE "-liconv -framework IOKit" "-framework CoreFoundation" -lc++) @@ -28,10 +20,9 @@ endif() set_property(GLOBAL PROPERTY USE_FOLDERS ON) -add_subdirectory(libnest2d) +# add_subdirectory(libnest2d) add_subdirectory(libslic3r) -add_subdirectory(slic3rutils) -add_subdirectory(fff_print) -# add_subdirectory(sla_print) -add_subdirectory(cpp17 EXCLUDE_FROM_ALL) # does not have to be built all the time -# add_subdirectory(example) +# add_subdirectory(slic3rutils) +# add_subdirectory(fff_print) +# add_subdirectory(cpp17 EXCLUDE_FROM_ALL) # does not have to be built all the time + diff --git a/tests/libslic3r/CMakeLists.txt b/tests/libslic3r/CMakeLists.txt index ea01e27e99..265feb660f 100644 --- a/tests/libslic3r/CMakeLists.txt +++ b/tests/libslic3r/CMakeLists.txt @@ -28,7 +28,7 @@ if (TARGET OpenVDB::openvdb) target_sources(${_TEST_NAME}_tests PRIVATE test_hollowing.cpp) endif() -target_link_libraries(${_TEST_NAME}_tests test_common libslic3r) +target_link_libraries(${_TEST_NAME}_tests test_common libslic3r Catch2::Catch2WithMain) set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests") if (WIN32) @@ -41,5 +41,4 @@ if (WIN32) endif() endif() -catch_discover_tests(${_TEST_NAME}_tests TEST_PREFIX "${_TEST_NAME}: ") -# add_test(${_TEST_NAME}_tests ${_TEST_NAME}_tests ${CATCH_EXTRA_ARGS}) +catch_discover_tests(${_TEST_NAME}_tests) diff --git a/tests/libslic3r/libslic3r_tests.cpp b/tests/libslic3r/libslic3r_tests.cpp index 770774da41..a46b69d124 100644 --- a/tests/libslic3r/libslic3r_tests.cpp +++ b/tests/libslic3r/libslic3r_tests.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Utils.hpp" #define NANOSVG_IMPLEMENTATION diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp index 8d389253aa..6323fcb860 100644 --- a/tests/libslic3r/test_3mf.cpp +++ b/tests/libslic3r/test_3mf.cpp @@ -1,4 +1,3 @@ -#include #include "libslic3r/Model.hpp" #include "libslic3r/Format/3mf.hpp" @@ -6,8 +5,62 @@ #include +#include +#include +#include +#include // for std::enable_if_t +#include // for typeid + +namespace Catch { + template + struct is_eigen_matrix : std::is_base_of, T> {}; + + template + struct StringMaker::value>> { + static std::string convert(const T& eigen_obj) { + // Newline at end of rows + Eigen::IOFormat fmt(4, 0, ", ", "\n", "[", "]"); + std::stringstream ss; + ss << "Matrix<" << typeid(eigen_obj).name() << "> = \n"; + ss << eigen_obj.format(fmt); + return ss.str(); + } + }; + + // We must manually specialize for Eigen::Transform as it doesn't derive from MatrixBase. + // It's defined as: Eigen::Transform + template + struct StringMaker> { + static std::string convert(const Eigen::Transform& trafo) { + // We print the underlying matrix + const auto& matrix = trafo.matrix(); + + // Newline at end of rows + Eigen::IOFormat fmt(4, 0, ", ", "\n", "[", "]"); + std::stringstream ss; + + ss << "Transform = \n"; + ss << matrix.format(fmt); + return ss.str(); + } + }; + + // Quaternions also need an explicit specialization + template + struct StringMaker> { + static std::string convert(const Eigen::Quaternion& quat) { + std::stringstream ss; + ss << "Quaternion(w=" << quat.w() << ", x=" << quat.x() << ", y=" << quat.y() << ", z=" << quat.z() << ")"; + return ss.str(); + } + }; +} // end namespace Catch + +#include + using namespace Slic3r; + SCENARIO("Reading 3mf file", "[3mf]") { GIVEN("umlauts in the path of the file") { Model model; @@ -89,17 +142,26 @@ SCENARIO("2D convex hull of sinking object", "[3mf]") { model.add_default_instances(); WHEN("model is rotated, scaled and set as sinking") { - ModelObject* object = model.objects.front(); + ModelObject* object = model.objects[0]; object->center_around_origin(false); - // set instance's attitude so that it is rotated, scaled and sinking - ModelInstance* instance = object->instances.front(); + // This outputs the same exact data as the Prusaslicer test + object->volumes[0]->mesh().write_ascii("/tmp/orca.ascii"); + + // set instance's attitude so that it is rotated, scaled (and sinking? how is it sinking? the rotation? does it matter if it's sinking?) + ModelInstance* instance = object->instances[0]; instance->set_rotation(X, -M_PI / 4.0); instance->set_offset(Vec3d::Zero()); instance->set_scaling_factor({ 2.0, 2.0, 2.0 }); // calculate 2D convex hull - Polygon hull_2d = object->convex_hull_2d(instance->get_transformation().get_matrix()); + auto trafo = instance->get_transformation().get_matrix(); + + // This matrix is the same exact matrix as the Prusaslicer test + CAPTURE(trafo); + Polygon hull_2d = object->convex_hull_2d(trafo); + + // But we get different hull_2d.points here (and somehow decimal numbers despite being int64_t values, but that's probabaly printing configuration somewhere -- Prusaslicer's prints out with newlines between the X&Y and not one between coordinates, which is about the worse possible output). // verify result Points result = { diff --git a/tests/libslic3r/test_aabbindirect.cpp b/tests/libslic3r/test_aabbindirect.cpp index 3b834c442e..f63f01cad1 100644 --- a/tests/libslic3r/test_aabbindirect.cpp +++ b/tests/libslic3r/test_aabbindirect.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include "test_utils.hpp" #include #include @@ -22,7 +22,7 @@ TEST_CASE("Building a tree over a box, ray caster and closest query", "[AABBIndi hit); REQUIRE(intersected); - REQUIRE(hit.t == Approx(5.)); + REQUIRE(hit.t == Catch::Approx(5.)); std::vector hits; bool intersected2 = AABBTreeIndirect::intersect_ray_all_hits( @@ -33,8 +33,8 @@ TEST_CASE("Building a tree over a box, ray caster and closest query", "[AABBIndi hits); REQUIRE(intersected2); REQUIRE(hits.size() == 2); - REQUIRE(hits.front().t == Approx(5.)); - REQUIRE(hits.back().t == Approx(6.)); + REQUIRE(hits.front().t == Catch::Approx(5.)); + REQUIRE(hits.back().t == Catch::Approx(6.)); size_t hit_idx; Vec3d closest_point; @@ -43,18 +43,18 @@ TEST_CASE("Building a tree over a box, ray caster and closest query", "[AABBIndi tree, Vec3d(0.3, 0.5, -5.), hit_idx, closest_point); - REQUIRE(squared_distance == Approx(5. * 5.)); - REQUIRE(closest_point.x() == Approx(0.3)); - REQUIRE(closest_point.y() == Approx(0.5)); - REQUIRE(closest_point.z() == Approx(0.)); + REQUIRE(squared_distance == Catch::Approx(5. * 5.)); + REQUIRE(closest_point.x() == Catch::Approx(0.3)); + REQUIRE(closest_point.y() == Catch::Approx(0.5)); + REQUIRE(closest_point.z() == Catch::Approx(0.)); squared_distance = AABBTreeIndirect::squared_distance_to_indexed_triangle_set( tmesh.its.vertices, tmesh.its.indices, tree, Vec3d(0.3, 0.5, 5.), hit_idx, closest_point); - REQUIRE(squared_distance == Approx(4. * 4.)); - REQUIRE(closest_point.x() == Approx(0.3)); - REQUIRE(closest_point.y() == Approx(0.5)); - REQUIRE(closest_point.z() == Approx(1.)); + REQUIRE(squared_distance == Catch::Approx(4. * 4.)); + REQUIRE(closest_point.x() == Catch::Approx(0.3)); + REQUIRE(closest_point.y() == Catch::Approx(0.5)); + REQUIRE(closest_point.z() == Catch::Approx(1.)); } diff --git a/tests/libslic3r/test_clipper_offset.cpp b/tests/libslic3r/test_clipper_offset.cpp index 8209d99bf7..3b855130be 100644 --- a/tests/libslic3r/test_clipper_offset.cpp +++ b/tests/libslic3r/test_clipper_offset.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -32,7 +32,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 22^2mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(22. * 22. * s * s)); + REQUIRE(output.front().area() == Catch::Approx(22. * 22. * s * s)); } } DYNAMIC_SECTION("minus 1mm, miter " << miter << "x") { @@ -46,7 +46,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 18^2mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(18. * 18. * s * s)); + REQUIRE(output.front().area() == Catch::Approx(18. * 18. * s * s)); } } } @@ -64,7 +64,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 22^2mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(22. * 22. * s * s)); + REQUIRE(output.front().area() == Catch::Approx(22. * 22. * s * s)); } } DYNAMIC_SECTION("minus 1mm, miter " << miter << "x") { @@ -78,7 +78,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 18^2mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(18. * 18. * s * s)); + REQUIRE(output.front().area() == Catch::Approx(18. * 18. * s * s)); } } } @@ -106,7 +106,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 22^2-8^2 mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx((22. * 22. - 8. * 8.) * s * s)); + REQUIRE(output.front().area() == Catch::Approx((22. * 22. - 8. * 8.) * s * s)); } } WHEN("minus 1mm") { @@ -120,7 +120,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 18^2-12^2 mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx((18. * 18. - 12. * 12.) * s * s)); + REQUIRE(output.front().area() == Catch::Approx((18. * 18. - 12. * 12.) * s * s)); } } } @@ -140,7 +140,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 22^2-8^2 mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx((22. * 22. - 8. * 8.) * s * s)); + REQUIRE(output.front().area() == Catch::Approx((22. * 22. - 8. * 8.) * s * s)); } } WHEN("minus 1mm") { @@ -154,7 +154,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area is 18^2-12^2 mm2") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx((18. * 18. - 12. * 12.) * s * s)); + REQUIRE(output.front().area() == Catch::Approx((18. * 18. - 12. * 12.) * s * s)); } } } @@ -186,7 +186,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area matches") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(area_offsetted)); + REQUIRE(output.front().area() == Catch::Approx(area_offsetted)); } } } @@ -205,7 +205,7 @@ SCENARIO("Constant offset", "[ClipperUtils]") { #endif THEN("Area matches") { REQUIRE(output.size() == 1); - REQUIRE(output.front().area() == Approx(area_offsetted)); + REQUIRE(output.front().area() == Catch::Approx(area_offsetted)); } } } diff --git a/tests/libslic3r/test_clipper_utils.cpp b/tests/libslic3r/test_clipper_utils.cpp index 6bbad8ef72..fe9961a771 100644 --- a/tests/libslic3r/test_clipper_utils.cpp +++ b/tests/libslic3r/test_clipper_utils.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -122,7 +122,7 @@ SCENARIO("Various Clipper operations - xs/t/11_clipper.t", "[ClipperUtils]") { REQUIRE(result.size() == 1); } THEN("intersection_pl - result has same length as subject polyline") { - REQUIRE(result.front().length() == Approx(subject.length())); + REQUIRE(result.front().length() == Catch::Approx(subject.length())); } } @@ -185,7 +185,7 @@ SCENARIO("Various Clipper operations - t/clipper.t", "[ClipperUtils]") { ExPolygon match({ { 20, 18 }, { 10, 18 }, { 10, 12 }, { 20, 12 } }, { { 14, 16 }, { 16, 16 }, { 16, 14 }, { 14, 14 } }); REQUIRE(intersection.size() == 1); - REQUIRE(intersection.front().area() == Approx(match.area())); + REQUIRE(intersection.front().area() == Catch::Approx(match.area())); } } } @@ -206,7 +206,7 @@ SCENARIO("Various Clipper operations - t/clipper.t", "[ClipperUtils]") { ExPolygons diff = Slic3r::diff_ex(Polygons{ square, square2 }, Polygons{ hole }); THEN("difference of a cw from two ccw is a contour with one hole") { REQUIRE(diff.size() == 1); - REQUIRE(diff.front().area() == Approx(ExPolygon({ {40, 40}, {0, 40}, {0, 0}, {40, 0} }, { {15, 25}, {25, 25}, {25, 15}, {15, 15} }).area())); + REQUIRE(diff.front().area() == Catch::Approx(ExPolygon({ {40, 40}, {0, 40}, {0, 0}, {40, 0} }, { {15, 25}, {25, 25}, {25, 15}, {15, 15} }).area())); } } } @@ -277,25 +277,25 @@ TEST_CASE("Traversing Clipper PolyTree", "[ClipperUtils]") { SECTION("Traverse into Polygons WITHOUT spatial ordering") { Polygons output; - REQUIRE(area_sum == Approx(polytree_area(tree.GetFirst(), &output))); + REQUIRE(area_sum == Catch::Approx(polytree_area(tree.GetFirst(), &output))); REQUIRE(output.size() == reference.size()); } SECTION("Traverse into ExPolygons WITHOUT spatial ordering") { ExPolygons output; - REQUIRE(area_sum == Approx(polytree_area(tree.GetFirst(), &output))); + REQUIRE(area_sum == Catch::Approx(polytree_area(tree.GetFirst(), &output))); REQUIRE(count_polys(output) == reference.size()); } SECTION("Traverse into Polygons WITH spatial ordering") { Polygons output; - REQUIRE(area_sum == Approx(polytree_area(tree.GetFirst(), &output))); + REQUIRE(area_sum == Catch::Approx(polytree_area(tree.GetFirst(), &output))); REQUIRE(output.size() == reference.size()); } SECTION("Traverse into ExPolygons WITH spatial ordering") { ExPolygons output; - REQUIRE(area_sum == Approx(polytree_area(tree.GetFirst(), &output))); + REQUIRE(area_sum == Catch::Approx(polytree_area(tree.GetFirst(), &output))); REQUIRE(count_polys(output) == reference.size()); } } diff --git a/tests/libslic3r/test_config.cpp b/tests/libslic3r/test_config.cpp index f98dbcab5d..ee7a681402 100644 --- a/tests/libslic3r/test_config.cpp +++ b/tests/libslic3r/test_config.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/PrintConfig.hpp" #include "libslic3r/PrintConfigConstants.hpp" diff --git a/tests/libslic3r/test_elephant_foot_compensation.cpp b/tests/libslic3r/test_elephant_foot_compensation.cpp index 09ad33f418..f509c6c0dd 100644 --- a/tests/libslic3r/test_elephant_foot_compensation.cpp +++ b/tests/libslic3r/test_elephant_foot_compensation.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/tests/libslic3r/test_geometry.cpp b/tests/libslic3r/test_geometry.cpp index 6be0479c1a..6607d5c36d 100644 --- a/tests/libslic3r/test_geometry.cpp +++ b/tests/libslic3r/test_geometry.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Point.hpp" #include "libslic3r/BoundingBox.hpp" diff --git a/tests/libslic3r/test_hollowing.cpp b/tests/libslic3r/test_hollowing.cpp index ad4f8f2961..bea399a05e 100644 --- a/tests/libslic3r/test_hollowing.cpp +++ b/tests/libslic3r/test_hollowing.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include "libslic3r/SLA/Hollowing.hpp" diff --git a/tests/libslic3r/test_indexed_triangle_set.cpp b/tests/libslic3r/test_indexed_triangle_set.cpp index adb70c11b5..8accf2b317 100644 --- a/tests/libslic3r/test_indexed_triangle_set.cpp +++ b/tests/libslic3r/test_indexed_triangle_set.cpp @@ -1,6 +1,7 @@ #include #include -#include +#include +#include #include "libslic3r/TriangleMesh.hpp" diff --git a/tests/libslic3r/test_marchingsquares.cpp b/tests/libslic3r/test_marchingsquares.cpp index 7af425ec0e..4768db5f7b 100644 --- a/tests/libslic3r/test_marchingsquares.cpp +++ b/tests/libslic3r/test_marchingsquares.cpp @@ -1,7 +1,7 @@ #define NOMINMAX -#include -#include +#include +#include "test_utils.hpp" #include diff --git a/tests/libslic3r/test_meshboolean.cpp b/tests/libslic3r/test_meshboolean.cpp index f1582fe3be..b7208349cc 100644 --- a/tests/libslic3r/test_meshboolean.cpp +++ b/tests/libslic3r/test_meshboolean.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include "test_utils.hpp" #include #include @@ -19,7 +19,7 @@ TEST_CASE("CGAL and TriangleMesh conversions", "[MeshBoolean]") { REQUIRE(M.its.vertices.size() == sphere.its.vertices.size()); REQUIRE(M.its.indices.size() == sphere.its.indices.size()); - REQUIRE(M.volume() == Approx(sphere.volume())); + REQUIRE(M.volume() == Catch::Approx(sphere.volume())); REQUIRE(! MeshBoolean::cgal::does_self_intersect(M)); } diff --git a/tests/libslic3r/test_mutable_polygon.cpp b/tests/libslic3r/test_mutable_polygon.cpp index 5a3c144410..906dffe50a 100644 --- a/tests/libslic3r/test_mutable_polygon.cpp +++ b/tests/libslic3r/test_mutable_polygon.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Point.hpp" #include "libslic3r/MutablePolygon.hpp" diff --git a/tests/libslic3r/test_mutable_priority_queue.cpp b/tests/libslic3r/test_mutable_priority_queue.cpp index 40ed5a1586..db7124df78 100644 --- a/tests/libslic3r/test_mutable_priority_queue.cpp +++ b/tests/libslic3r/test_mutable_priority_queue.cpp @@ -1,6 +1,7 @@ -#include +#include #include +#include #include "libslic3r/MutablePriorityQueue.hpp" diff --git a/tests/libslic3r/test_optimizers.cpp b/tests/libslic3r/test_optimizers.cpp index 6e84f6a691..8783ac1428 100644 --- a/tests/libslic3r/test_optimizers.cpp +++ b/tests/libslic3r/test_optimizers.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include "test_utils.hpp" #include diff --git a/tests/libslic3r/test_placeholder_parser.cpp b/tests/libslic3r/test_placeholder_parser.cpp index f7b6748bff..2394aad4bf 100644 --- a/tests/libslic3r/test_placeholder_parser.cpp +++ b/tests/libslic3r/test_placeholder_parser.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/PlaceholderParser.hpp" #include "libslic3r/PrintConfig.hpp" @@ -33,17 +33,17 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { // FIXME: Don't know what exactly this referred to in Prusaslicer or // whether it should apply to Orca or not. // {outer_wall_line_width} returns as its default value, 0. - // SECTION("outer_wall_line_width") { REQUIRE(std::stod(parser.process("{outer_wall_line_width}")) == Approx(0.67500001192092896)); } - SECTION("support_object_xy_distance") { REQUIRE(std::stod(parser.process("{support_object_xy_distance}")) == Approx(0.35)); } + // SECTION("outer_wall_line_width") { REQUIRE(std::stod(parser.process("{outer_wall_line_width}")) == Catch::Approx(0.67500001192092896)); } + SECTION("support_object_xy_distance") { REQUIRE(std::stod(parser.process("{support_object_xy_distance}")) == Catch::Approx(0.35)); } // initial_layer_line_width ratio over nozzle_diameter. // FIXME: either something else which correctly calculates a ratio should be here, // or something else should be found for for the REQUIRE_THROWS - // SECTION("initial_layer_line_width") { REQUIRE(std::stod(parser.process("{initial_layer_line_width}")) == Approx(0.9)); } + // SECTION("initial_layer_line_width") { REQUIRE(std::stod(parser.process("{initial_layer_line_width}")) == Catch::Approx(0.9)); } // small_perimeter_speed ratio over outer_wall_speed - SECTION("small_perimeter_speed") { REQUIRE(std::stod(parser.process("{small_perimeter_speed}")) == Approx(30.)); } + SECTION("small_perimeter_speed") { REQUIRE(std::stod(parser.process("{small_perimeter_speed}")) == Catch::Approx(30.)); } // infill_wall_overlap over inner_wall_line_width // FIXME: Shouldn't this return the calculated value and not the percentage 15? - // SECTION("infill_wall_overlap") { REQUIRE(std::stod(parser.process("{infill_wall_overlap}")) == Approx(0.16875)); } + // SECTION("infill_wall_overlap") { REQUIRE(std::stod(parser.process("{infill_wall_overlap}")) == Catch::Approx(0.16875)); } // If initial_layer_line_width is set to percent, then it is applied over respective extrusion types by overriding their respective speeds. // The PlaceholderParser has no way to know which extrusion type the caller has in mind, therefore it throws. @@ -53,17 +53,17 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { SECTION("math: 2*3") { REQUIRE(parser.process("{2*3}") == "6"); } SECTION("math: 2*3/6") { REQUIRE(parser.process("{2*3/6}") == "1"); } SECTION("math: 2*3/12") { REQUIRE(parser.process("{2*3/12}") == "0"); } - SECTION("math: 2.*3/12") { REQUIRE(std::stod(parser.process("{2.*3/12}")) == Approx(0.5)); } - SECTION("math: 10 % 2.5") { REQUIRE(std::stod(parser.process("{10%2.5}")) == Approx(0.)); } - SECTION("math: 11 % 2.5") { REQUIRE(std::stod(parser.process("{11%2.5}")) == Approx(1.)); } + SECTION("math: 2.*3/12") { REQUIRE(std::stod(parser.process("{2.*3/12}")) == Catch::Approx(0.5)); } + SECTION("math: 10 % 2.5") { REQUIRE(std::stod(parser.process("{10%2.5}")) == Catch::Approx(0.)); } + SECTION("math: 11 % 2.5") { REQUIRE(std::stod(parser.process("{11%2.5}")) == Catch::Approx(1.)); } SECTION("math: 2*(3-12)") { REQUIRE(parser.process("{2*(3-12)}") == "-18"); } SECTION("math: 2*foo*(3-12)") { REQUIRE(parser.process("{2*foo*(3-12)}") == "0"); } SECTION("math: 2*bar*(3-12)") { REQUIRE(parser.process("{2*bar*(3-12)}") == "-36"); } - SECTION("math: 2.5*bar*(3-12)") { REQUIRE(std::stod(parser.process("{2.5*bar*(3-12)}")) == Approx(-45)); } + SECTION("math: 2.5*bar*(3-12)") { REQUIRE(std::stod(parser.process("{2.5*bar*(3-12)}")) == Catch::Approx(-45)); } SECTION("math: min(12, 14)") { REQUIRE(parser.process("{min(12, 14)}") == "12"); } SECTION("math: max(12, 14)") { REQUIRE(parser.process("{max(12, 14)}") == "14"); } - SECTION("math: min(13.4, -1238.1)") { REQUIRE(std::stod(parser.process("{min(13.4, -1238.1)}")) == Approx(-1238.1)); } - SECTION("math: max(13.4, -1238.1)") { REQUIRE(std::stod(parser.process("{max(13.4, -1238.1)}")) == Approx(13.4)); } + SECTION("math: min(13.4, -1238.1)") { REQUIRE(std::stod(parser.process("{min(13.4, -1238.1)}")) == Catch::Approx(-1238.1)); } + SECTION("math: max(13.4, -1238.1)") { REQUIRE(std::stod(parser.process("{max(13.4, -1238.1)}")) == Catch::Approx(13.4)); } SECTION("math: int(13.4)") { REQUIRE(parser.process("{int(13.4)}") == "13"); } SECTION("math: int(-13.4)") { REQUIRE(parser.process("{int(-13.4)}") == "-13"); } SECTION("math: round(13.4)") { REQUIRE(parser.process("{round(13.4)}") == "13"); } @@ -80,9 +80,9 @@ SCENARIO("Placeholder parser scripting", "[PlaceholderParser]") { SECTION("math: zdigits(5., 15, 8)") { REQUIRE(parser.process("{zdigits(5, 15, 8)}") == "000005.00000000"); } SECTION("math: digits(13.84375892476, 15, 8)") { REQUIRE(parser.process("{digits(13.84375892476, 15, 8)}") == " 13.84375892"); } SECTION("math: zdigits(13.84375892476, 15, 8)") { REQUIRE(parser.process("{zdigits(13.84375892476, 15, 8)}") == "000013.84375892"); } - SECTION("math: interpolate_table(13.84375892476, (0, 0), (20, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(13.84375892476, (0, 0), (20, 20))}")) == Approx(13.84375892476)); } - SECTION("math: interpolate_table(13, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(13, (0, 0), (20, 20), (30, 20))}")) == Approx(13.)); } - SECTION("math: interpolate_table(25, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(25, (0, 0), (20, 20), (30, 20))}")) == Approx(20.)); } + SECTION("math: interpolate_table(13.84375892476, (0, 0), (20, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(13.84375892476, (0, 0), (20, 20))}")) == Catch::Approx(13.84375892476)); } + SECTION("math: interpolate_table(13, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(13, (0, 0), (20, 20), (30, 20))}")) == Catch::Approx(13.)); } + SECTION("math: interpolate_table(25, (0, 0), (20, 20), (30, 20))") { REQUIRE(std::stod(parser.process("{interpolate_table(25, (0, 0), (20, 20), (30, 20))}")) == Catch::Approx(20.)); } // Test the boolean expression parser. auto boolean_expression = [&parser](const std::string& templ) { return parser.evaluate_boolean_expression(templ, parser.config()); }; diff --git a/tests/libslic3r/test_png_io.cpp b/tests/libslic3r/test_png_io.cpp index b4fcd6255d..f7852a19de 100644 --- a/tests/libslic3r/test_png_io.cpp +++ b/tests/libslic3r/test_png_io.cpp @@ -1,5 +1,5 @@ #define NOMINMAX -#include +#include #include diff --git a/tests/libslic3r/test_polygon.cpp b/tests/libslic3r/test_polygon.cpp index f2c78cacec..feae4ff50c 100644 --- a/tests/libslic3r/test_polygon.cpp +++ b/tests/libslic3r/test_polygon.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Point.hpp" #include "libslic3r/Polygon.hpp" diff --git a/tests/libslic3r/test_stl.cpp b/tests/libslic3r/test_stl.cpp index 4c9c1bcbb6..a8addeca16 100644 --- a/tests/libslic3r/test_stl.cpp +++ b/tests/libslic3r/test_stl.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Model.hpp" #include "libslic3r/Format/STL.hpp" diff --git a/tests/libslic3r/test_timeutils.cpp b/tests/libslic3r/test_timeutils.cpp index 6630d7055b..221dd07d81 100644 --- a/tests/libslic3r/test_timeutils.cpp +++ b/tests/libslic3r/test_timeutils.cpp @@ -1,4 +1,4 @@ -#include +#include #include "libslic3r/Time.hpp" diff --git a/tests/libslic3r/test_voronoi.cpp b/tests/libslic3r/test_voronoi.cpp index d4da904677..b86f448c02 100644 --- a/tests/libslic3r/test_voronoi.cpp +++ b/tests/libslic3r/test_voronoi.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include "test_utils.hpp" #include #include @@ -10,6 +10,7 @@ #include #include +#include // #define VORONOI_DEBUG_OUT @@ -70,7 +71,7 @@ TEST_CASE("Voronoi missing edges - points 12067", "[Voronoi]") vd, pts, Lines()); #endif -// REQUIRE(closest_point.z() == Approx(1.)); +// REQUIRE(closest_point.z() == Catch::Approx(1.)); } // https://svn.boost.org/trac10/ticket/12707 @@ -341,7 +342,7 @@ TEST_CASE("Voronoi division by zero 12903", "[Voronoi]") // Funny sample from a dental industry? // Vojtech confirms this test fails and rightly so, because the input data contain self intersections. // This test is suppressed. -TEST_CASE("Voronoi NaN coordinates 12139", "[Voronoi][!hide][!mayfail]") +TEST_CASE("Voronoi NaN coordinates 12139", "[Voronoi][.][!mayfail]") { Lines lines = { { { 260500,1564400 }, { 261040,1562960 } },