Fixed unit tests.

This commit is contained in:
Vojtech Bubnik 2021-03-09 13:54:42 +01:00
parent f01f02154c
commit adcbe4347c
6 changed files with 24 additions and 20 deletions

View file

@ -96,7 +96,7 @@ SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
ConfigOptionFloatOrPercent width(1.0, false);
float nozzle_diameter = 0.4f;
float layer_height = 0.5f;
float layer_height = 0.4f;
// Spacing for non-bridges is has some overlap
THEN("External perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
@ -126,8 +126,8 @@ SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));
}
}
WHEN("Layer height is set to 0.2") {
layer_height = 0.3f;
WHEN("Layer height is set to 0.25") {
layer_height = 0.25f;
THEN("Min width is set.") {
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));

View file

@ -53,8 +53,8 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
config.set_deserialize({
{ "top_solid_layers", 2 },
{ "bottom_solid_layers", 1 },
{ "layer_height", 0.5 }, // get a known number of layers
{ "first_layer_height", 0.5 }
{ "layer_height", 0.25 }, // get a known number of layers
{ "first_layer_height", 0.25 }
});
Slic3r::Print print;
Slic3r::Model model;
@ -72,8 +72,8 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
};
print.process();
test_is_solid_infill(0, 0); // should be solid
test_is_solid_infill(0, 39); // should be solid
test_is_solid_infill(0, 38); // should be solid
test_is_solid_infill(0, 79); // should be solid
test_is_solid_infill(0, 78); // should be solid
WHEN("Model is re-sliced with top_solid_layers == 3") {
config.set("top_solid_layers", 3);
print.apply(model, config);
@ -82,9 +82,9 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
test_is_solid_infill(0, 0);
}
AND_THEN("Print object has 3 top solid layers") {
test_is_solid_infill(0, 39);
test_is_solid_infill(0, 38);
test_is_solid_infill(0, 37);
test_is_solid_infill(0, 79);
test_is_solid_infill(0, 78);
test_is_solid_infill(0, 77);
}
}
}

View file

@ -244,23 +244,24 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
{ "complete_objects", true },
{ "gcode_comments", true },
{ "layer_gcode", ";Layer:[layer_num] ([layer_z] mm)" },
{ "layer_height", 1.0 },
{ "first_layer_height", 1.0 }
{ "layer_height", 0.1 },
{ "first_layer_height", 0.1 }
});
// End of the 1st object.
size_t pos = gcode.find(";Layer:19 ");
std::string token = ";Layer:199 ";
size_t pos = gcode.find(token);
THEN("First and second object last layer is emitted") {
// First object
REQUIRE(pos != std::string::npos);
pos += 10;
pos += token.size();
REQUIRE(pos < gcode.size());
double z = 0;
REQUIRE((sscanf(gcode.data() + pos, "(%lf mm)", &z) == 1));
REQUIRE(z == Approx(20.));
// Second object
pos = gcode.find(";Layer:39 ", pos);
pos = gcode.find(";Layer:399 ", pos);
REQUIRE(pos != std::string::npos);
pos += 10;
pos += token.size();
REQUIRE(pos < gcode.size());
REQUIRE((sscanf(gcode.data() + pos, "(%lf mm)", &z) == 1));
REQUIRE(z == Approx(20.));