From 90d57120911074b7976ece156d35190c7d71c40c Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 16 Oct 2019 09:28:27 +0200 Subject: [PATCH] Filling in the autos in the tests so it is readible and it compiles on OSX --- tests/fff_print/test_skirt_brim.cpp | 32 +++++++++---------- tests/fff_print/test_trianglemesh.cpp | 44 +++++++++++++-------------- tests/libslic3r/test_geometry.cpp | 22 +++++++------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/fff_print/test_skirt_brim.cpp b/tests/fff_print/test_skirt_brim.cpp index 0bef2b627..64c548d3f 100644 --- a/tests/fff_print/test_skirt_brim.cpp +++ b/tests/fff_print/test_skirt_brim.cpp @@ -39,7 +39,7 @@ TEST_CASE("Skirt height is honored") { // avoid altering speeds unexpectedly config->set_deserialize("cooling", "0"); config->set_deserialize("first_layer_speed", "100%"); - auto support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; + double support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; std::map layers_with_skirt; std::string gcode; @@ -47,12 +47,12 @@ TEST_CASE("Skirt height is honored") { Slic3r::Model model; SECTION("printing a single object") { - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); gcode = Slic3r::Test::gcode(print); } SECTION("printing multiple objects") { - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20, TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20, TestMesh::cube_20x20x20}, model, config); gcode = Slic3r::Test::gcode(print); } parser.parse_buffer(gcode, [&layers_with_skirt, &support_speed] (Slic3r::GCodeReader& self, const Slic3r::GCodeReader::GCodeLine& line) @@ -66,7 +66,7 @@ TEST_CASE("Skirt height is honored") { } SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { - auto parser {Slic3r::GCodeReader()}; + Slic3r::GCodeReader parser; Slic3r::Model model; std::string gcode; GIVEN("A default configuration") { @@ -88,10 +88,10 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->opt_int("skirts") = 0; config->opt_float("brim_width") = 5; THEN("Brim is generated") { - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); gcode = Slic3r::Test::gcode(print); bool brim_generated = false; - auto support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; + double support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; parser.parse_buffer(gcode, [&brim_generated, support_speed] (Slic3r::GCodeReader& self, const Slic3r::GCodeReader::GCodeLine& line) { if (self.z() == Approx(0.3) || line.new_Z(self) == Approx(0.3)) { @@ -107,7 +107,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { WHEN("Skirt area is smaller than the brim") { config->opt_int("skirts") = 1; config->opt_float("brim_width") = 10; - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); THEN("Gcode generates") { REQUIRE(! Slic3r::Test::gcode(print).empty()); } @@ -117,7 +117,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->opt_int("skirts") = 2; config->opt_int("skirt_height") = 0; - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); THEN("Gcode generates") { REQUIRE(! Slic3r::Test::gcode(print).empty()); } @@ -129,7 +129,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->opt_int("perimeter_extruder") = 2; config->opt_int("support_material_extruder") = 3; THEN("Brim is printed with the extruder used for the perimeters of first object") { - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); gcode = Slic3r::Test::gcode(print); int tool = get_brim_tool(gcode, parser); REQUIRE(tool == config->opt_int("perimeter_extruder") - 1); @@ -142,7 +142,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->opt_int("support_material_extruder") = 3; config->opt_int("raft_layers") = 1; THEN("brim is printed with same extruder as skirt") { - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); gcode = Slic3r::Test::gcode(print); int tool = get_brim_tool(gcode, parser); REQUIRE(tool == config->opt_int("support_material_extruder") - 1); @@ -155,7 +155,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { THEN("2 brim lines") { Slic3r::Model model; - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); print->process(); REQUIRE(print->brim().entities.size() == 2); } @@ -170,7 +170,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->set("brim_ears_max_angle", 91); Slic3r::Model model; - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); print->process(); THEN("Four brim ears") { @@ -187,7 +187,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { THEN("no brim") { Slic3r::Model model; - auto print {Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); print->process(); REQUIRE(print->brim.size() == 0); } @@ -207,7 +207,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { config->set_deserialize("first_layer_speed", "100%"); // to prevent speeds to be altered Slic3r::Model model; - auto print {Slic3r::Test::init_print({TestMesh::overhang}, model, config)}; + auto print = Slic3r::Test::init_print({TestMesh::overhang}, model, config); print->process(); // config->set("support_material", true); // to prevent speeds to be altered @@ -221,7 +221,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { auto print = Slic3r::Test::init_print({TestMesh::cube_20x20x20}, model, config); std::string gcode = Slic3r::Test::gcode(print); - auto support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; + double support_speed = config->opt("support_material_speed")->value * MM_PER_MIN; parser.parse_buffer(gcode, [config, &extrusion_points, &tool, &skirt_length, support_speed] (Slic3r::GCodeReader& self, const Slic3r::GCodeReader::GCodeLine& line) { // std::cerr << line.cmd() << "\n"; @@ -230,7 +230,7 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") { } else if (self.z() == Approx(config->opt("first_layer_height")->value)) { // on first layer if (line.extruding(self) && line.dist_XY(self) > 0) { - auto speed = ( self.f() > 0 ? self.f() : line.new_F(self)); + float speed = ( self.f() > 0 ? self.f() : line.new_F(self)); // std::cerr << "Tool " << tool << "\n"; if (speed == Approx(support_speed) && tool == config->opt_int("perimeter_extruder") - 1) { // Skirt uses first material extruder, support material speed. diff --git a/tests/fff_print/test_trianglemesh.cpp b/tests/fff_print/test_trianglemesh.cpp index 8e099db75..e24a77e7f 100644 --- a/tests/fff_print/test_trianglemesh.cpp +++ b/tests/fff_print/test_trianglemesh.cpp @@ -28,10 +28,10 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { } THEN( "Vertices array matches input.") { - for (auto i = 0U; i < cube.its.vertices.size(); i++) { + for (size_t i = 0U; i < cube.its.vertices.size(); i++) { REQUIRE(cube.its.vertices.at(i) == vertices.at(i).cast()); } - for (auto i = 0U; i < vertices.size(); i++) { + for (size_t i = 0U; i < vertices.size(); i++) { REQUIRE(vertices.at(i).cast() == cube.its.vertices.at(i)); } } @@ -40,11 +40,11 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { } THEN( "Facet array matches input.") { - for (auto i = 0U; i < cube.its.indices.size(); i++) { + for (size_t i = 0U; i < cube.its.indices.size(); i++) { REQUIRE(cube.its.indices.at(i) == facets.at(i)); } - for (auto i = 0U; i < facets.size(); i++) { + for (size_t i = 0U; i < facets.size(); i++) { REQUIRE(facets.at(i) == cube.its.indices.at(i)); } } @@ -79,10 +79,10 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { } THEN( "Vertices array matches input.") { - for (auto i = 0U; i < cube.its.vertices.size(); i++) { + for (size_t i = 0U; i < cube.its.vertices.size(); i++) { REQUIRE(cube.its.vertices.at(i) == vertices.at(i).cast()); } - for (auto i = 0U; i < vertices.size(); i++) { + for (size_t i = 0U; i < vertices.size(); i++) { REQUIRE(vertices.at(i).cast() == cube.its.vertices.at(i)); } } @@ -91,11 +91,11 @@ SCENARIO( "TriangleMesh: Basic mesh statistics") { } THEN( "Facet array matches input.") { - for (auto i = 0U; i < cube.its.indices.size(); i++) { + for (size_t i = 0U; i < cube.its.indices.size(); i++) { REQUIRE(cube.its.indices.at(i) == facets.at(i)); } - for (auto i = 0U; i < facets.size(); i++) { + for (size_t i = 0U; i < facets.size(); i++) { REQUIRE(facets.at(i) == cube.its.indices.at(i)); } } @@ -191,14 +191,14 @@ SCENARIO( "TriangleMesh: slice behavior.") { WHEN("Cube is sliced with z = [0+EPSILON,2,4,8,6,8,10,12,14,16,18,20]") { std::vector z { 0+EPSILON,2,4,8,6,8,10,12,14,16,18,20 }; - auto result {cube.slice(z)}; + std::vector result = cube.slice(z); THEN( "The correct number of polygons are returned per layer.") { - for (auto i = 0U; i < z.size(); i++) { + for (size_t i = 0U; i < z.size(); i++) { REQUIRE(result.at(i).size() == 1); } } THEN( "The area of the returned polygons is correct.") { - for (auto i = 0U; i < z.size(); i++) { + for (size_t i = 0U; i < z.size(); i++) { REQUIRE(result.at(i).at(0).area() == 20.0*20/(std::pow(SCALING_FACTOR,2))); } } @@ -211,7 +211,7 @@ SCENARIO( "TriangleMesh: slice behavior.") { TriangleMesh cube(vertices, facets); cube.repair(); WHEN(" a top tangent plane is sliced") { - auto slices {cube.slice({5.0, 10.0})}; + std::vector slices = cube.slice({5.0, 10.0}); THEN( "its area is included") { REQUIRE(slices.at(0).at(0).area() > 0); REQUIRE(slices.at(1).at(0).area() > 0); @@ -219,7 +219,7 @@ SCENARIO( "TriangleMesh: slice behavior.") { } WHEN(" a model that has been transformed is sliced") { cube.mirror_z(); - auto slices {cube.slice({-5.0, -10.0})}; + std::vector slices = cube.slice({-5.0, -10.0}); THEN( "it is sliced properly (mirrored bottom plane area is included)") { REQUIRE(slices.at(0).at(0).area() > 0); REQUIRE(slices.at(1).at(0).area() > 0); @@ -233,7 +233,7 @@ SCENARIO( "make_xxx functions produce meshes.") { WHEN("make_cube() is called with arguments 20,20,20") { TriangleMesh cube = make_cube(20,20,20); THEN("The resulting mesh has one and only one vertex at 0,0,0") { - auto verts {cube.its.vertices}; + const std::vector &verts = cube.its.vertices; REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return t.x() == 0 && t.y() == 0 && t.z() == 0; } ) == 1); } THEN("The mesh volume is 20*20*20") { @@ -252,11 +252,11 @@ SCENARIO( "make_xxx functions produce meshes.") { TriangleMesh cyl = make_cylinder(10, 10, PI / 243.0); double angle = (2*PI / floor(2*PI / (PI / 243.0))); THEN("The resulting mesh has one and only one vertex at 0,0,0") { - auto verts {cyl.its.vertices}; + const std::vector &verts = cyl.its.vertices; REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return t.x() == 0 && t.y() == 0 && t.z() == 0; } ) == 1); } THEN("The resulting mesh has one and only one vertex at 0,0,10") { - auto verts {cyl.its.vertices}; + const std::vector &verts = cyl.its.vertices; REQUIRE(std::count_if(verts.begin(), verts.end(), [](const Vec3f& t) { return t.x() == 0 && t.y() == 0 && t.z() == 10; } ) == 1); } THEN("Resulting mesh has 2 + (2*PI/angle * 2) vertices.") { @@ -301,7 +301,7 @@ SCENARIO( "TriangleMesh: split functionality.") { TriangleMesh cube(vertices, facets); cube.repair(); WHEN( "The mesh is split into its component parts.") { - auto meshes {cube.split()}; + std::vector meshes = cube.split(); THEN(" The bounding box statistics are propagated to the split copies") { REQUIRE(meshes.size() == 1); REQUIRE((meshes.at(0)->bounding_box() == cube.bounding_box())); @@ -320,7 +320,7 @@ SCENARIO( "TriangleMesh: split functionality.") { cube.merge(cube2); cube.repair(); WHEN( "The combined mesh is split") { - auto meshes {cube.split()}; + std::vector meshes = cube.split(); THEN( "Two meshes are in the output vector.") { REQUIRE(meshes.size() == 2); } @@ -384,7 +384,7 @@ SCENARIO( "TriangleMeshSlicer: Cut behavior.") { #ifdef TEST_PERFORMANCE TEST_CASE("Regression test for issue #4486 - files take forever to slice") { TriangleMesh mesh; - auto config {Slic3r::Config::new_from_defaults()}; + std::shared_ptr config = Slic3r::DynamicPrintConfig::new_from_defaults(); mesh.ReadSTLFile(std::string(testfile_dir) + "test_trianglemesh/4486/100_000.stl"); mesh.repair(); @@ -393,7 +393,7 @@ TEST_CASE("Regression test for issue #4486 - files take forever to slice") { config->set("nozzle_diameter", 500); Slic3r::Model model; - auto print {Slic3r::Test::init_print({mesh}, model, config)}; + auto print = Slic3r::Test::init_print({mesh}, model, config); print->status_cb = [] (int ln, const std::string& msg) { Slic3r::Log::info("Print") << ln << " " << msg << "\n";}; @@ -411,7 +411,7 @@ TEST_CASE("Regression test for issue #4486 - files take forever to slice") { #ifdef BUILD_PROFILE TEST_CASE("Profile test for issue #4486 - files take forever to slice") { TriangleMesh mesh; - auto config {Slic3r::Config::new_from_defaults()}; + std::shared_ptr config = Slic3r::DynamicPrintConfig::new_from_defaults(); mesh.ReadSTLFile(std::string(testfile_dir) + "test_trianglemesh/4486/10_000.stl"); mesh.repair(); @@ -421,7 +421,7 @@ TEST_CASE("Profile test for issue #4486 - files take forever to slice") { config->set("fill_density", "5%"); Slic3r::Model model; - auto print {Slic3r::Test::init_print({mesh}, model, config)}; + auto print = Slic3r::Test::init_print({mesh}, model, config); print->status_cb = [] (int ln, const std::string& msg) { Slic3r::Log::info("Print") << ln << " " << msg << "\n";}; diff --git a/tests/libslic3r/test_geometry.cpp b/tests/libslic3r/test_geometry.cpp index 7a3b84c7d..fce6a476c 100644 --- a/tests/libslic3r/test_geometry.cpp +++ b/tests/libslic3r/test_geometry.cpp @@ -13,7 +13,7 @@ using namespace Slic3r; TEST_CASE("Polygon::contains works properly", ""){ // this test was failing on Windows (GH #1950) - auto polygon = Slic3r::Polygon(std::vector({ + Slic3r::Polygon polygon(std::vector({ Point(207802834,-57084522), Point(196528149,-37556190), Point(173626821,-25420928), @@ -25,14 +25,14 @@ TEST_CASE("Polygon::contains works properly", ""){ Point(129714478,-84542120), Point(160244873,-84542120) })); - auto point = Point(95706562, -57294774); + Point point(95706562, -57294774); REQUIRE(polygon.contains(point)); } SCENARIO("Intersections of line segments"){ GIVEN("Integer coordinates"){ - auto line1 = Line(Point(5,15),Point(30,15)); - auto line2 = Line(Point(10,20), Point(10,10)); + Line line1(Point(5,15),Point(30,15)); + Line line2(Point(10,20), Point(10,10)); THEN("The intersection is valid"){ Point point; line1.intersection(line2,&point); @@ -41,8 +41,8 @@ SCENARIO("Intersections of line segments"){ } GIVEN("Scaled coordinates"){ - auto line1 = Line(Point(73.6310778185108 / 0.00001, 371.74239268924 / 0.00001), Point(73.6310778185108 / 0.00001, 501.74239268924 / 0.00001)); - auto line2 = Line(Point(75/0.00001, 437.9853/0.00001), Point(62.7484/0.00001, 440.4223/0.00001)); + Line line1(Point(73.6310778185108 / 0.00001, 371.74239268924 / 0.00001), Point(73.6310778185108 / 0.00001, 501.74239268924 / 0.00001)); + Line line2(Point(75/0.00001, 437.9853/0.00001), Point(62.7484/0.00001, 440.4223/0.00001)); THEN("There is still an intersection"){ Point point; REQUIRE(line1.intersection(line2,&point)); @@ -128,7 +128,7 @@ SCENARIO("polygon_is_convex works"){ TEST_CASE("Creating a polyline generates the obvious lines"){ - auto polyline = Slic3r::Polyline(); + Slic3r::Polyline polyline; polyline.points = std::vector({Point(0, 0), Point(10, 0), Point(20, 0)}); REQUIRE(polyline.lines().at(0).a == Point(0,0)); REQUIRE(polyline.lines().at(0).b == Point(10,0)); @@ -137,8 +137,8 @@ TEST_CASE("Creating a polyline generates the obvious lines"){ } TEST_CASE("Splitting a Polygon generates a polyline correctly"){ - auto polygon = Slic3r::Polygon(std::vector({Point(0, 0), Point(10, 0), Point(5, 5)})); - auto split = polygon.split_at_index(1); + Slic3r::Polygon polygon(std::vector({Point(0, 0), Point(10, 0), Point(5, 5)})); + Slic3r::Polyline split = polygon.split_at_index(1); REQUIRE(split.points[0]==Point(10,0)); REQUIRE(split.points[1]==Point(5,5)); REQUIRE(split.points[2]==Point(0,0)); @@ -147,7 +147,7 @@ TEST_CASE("Splitting a Polygon generates a polyline correctly"){ TEST_CASE("Bounding boxes are scaled appropriately"){ - auto bb = BoundingBox(std::vector({Point(0, 1), Point(10, 2), Point(20, 2)})); + BoundingBox bb(std::vector({Point(0, 1), Point(10, 2), Point(20, 2)})); bb.scale(2); REQUIRE(bb.min == Point(0,2)); REQUIRE(bb.max == Point(40,4)); @@ -265,7 +265,7 @@ TEST_CASE("Chained path working correctly"){ SCENARIO("Line distances"){ GIVEN("A line"){ - auto line = Line(Point(0, 0), Point(20, 0)); + Line line(Point(0, 0), Point(20, 0)); THEN("Points on the line segment have 0 distance"){ REQUIRE(line.distance_to(Point(0, 0)) == 0); REQUIRE(line.distance_to(Point(20, 0)) == 0);