diff --git a/src/test/libslic3r/test_printobject.cpp b/src/test/libslic3r/test_printobject.cpp index 3c0b2c4f8b..52046f81e9 100644 --- a/src/test/libslic3r/test_printobject.cpp +++ b/src/test/libslic3r/test_printobject.cpp @@ -7,15 +7,16 @@ using namespace Slic3r::Test; using namespace std::literals; SCENARIO("PrintObject: object layer heights") { - GIVEN("20mm cube and config that has a 3mm nozzle and a 2mm requested layer height") { + GIVEN("20mm cube and default initial config, initial layer height of 2mm") { auto config {Slic3r::Config::new_from_defaults()}; TestMesh m { TestMesh::cube_20x20x20 }; Slic3r::Model model; - config->set("nozzle_diameter", "3"); - config->set("layer_height", 2.0); + config->set("first_layer_height", 2.0); - WHEN("generate_object_layers() is called with a starting layer of 2mm") { + WHEN("generate_object_layers() is called for 2mm layer heights and nozzle diameter of 3mm") { + config->set("nozzle_diameter", "3"); + config->set("layer_height", 2.0); auto print {Slic3r::Test::init_print({m}, model, config)}; auto result {print->objects[0]->generate_object_layers(2.0)}; THEN("The output vector has 10 entries") { @@ -29,5 +30,50 @@ SCENARIO("PrintObject: object layer heights") { } } } + WHEN("generate_object_layers() is called for 10mm layer heights and nozzle diameter of 11mm") { + config->set("nozzle_diameter", "11"); + config->set("layer_height", 10.0); + auto print {Slic3r::Test::init_print({m}, model, config)}; + auto result {print->objects[0]->generate_object_layers(2.0)}; + THEN("The output vector has 2 entries") { + REQUIRE(result.size() == 3); + } + AND_THEN("Layer 0 is at 2mm") { + REQUIRE(result[0] == Approx(2.0)); + } + AND_THEN("Layer 1 is at 12mm") { + REQUIRE(result[1] == Approx(12.0)); + } + } + WHEN("generate_object_layers() is called for 15mm layer heights and nozzle diameter of 16mm") { + config->set("nozzle_diameter", "16"); + config->set("layer_height", 15.0); + auto print {Slic3r::Test::init_print({m}, model, config)}; + auto result {print->objects[0]->generate_object_layers(2.0)}; + THEN("The output vector has 2 entries") { + REQUIRE(result.size() == 3); + } + AND_THEN("Layer 0 is at 2mm") { + REQUIRE(result[0] == Approx(2.0)); + } + AND_THEN("Layer 1 is at 17mm") { + REQUIRE(result[1] == Approx(17.0)); + } + } + WHEN("generate_object_layers() is called for 15mm layer heights and nozzle diameter of 5mm") { + config->set("nozzle_diameter", "5"); + config->set("layer_height", 15.0); + auto print {Slic3r::Test::init_print({m}, model, config)}; + auto result {print->objects[0]->generate_object_layers(2.0)}; + THEN("The layer height is limited to 5mm.") { + CHECK(result.size() == 5); + coordf_t last = 2.0; + for (size_t i = 1; i < result.size(); i++) { + REQUIRE((result[i] - last) == Approx(5.0)); + last = result[i]; + } + } + } + } }