Fixes of unit tests on OSX. The old clang does not like the way
@lordofhyphens uses the initializer lists together with autos.
This commit is contained in:
parent
76c4eaf19a
commit
fee4dc3fc0
2 changed files with 22 additions and 29 deletions
tests/fff_print
|
@ -13,10 +13,10 @@ SCENARIO("PrintObject: Perimeter generation", "[PrintObject]") {
|
||||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||||
TestMesh m = TestMesh::cube_20x20x20;
|
TestMesh m = TestMesh::cube_20x20x20;
|
||||||
Slic3r::Model model;
|
Slic3r::Model model;
|
||||||
auto event_counter {0U};
|
size_t event_counter = 0;
|
||||||
std::string stage;
|
std::string stage;
|
||||||
int value {0};
|
int value = 0;
|
||||||
auto callback {[&event_counter, &stage, &value] (int a, const char* b) { stage = std::string(b); event_counter++; value = a; }};
|
auto callback = [&event_counter, &stage, &value] (int a, const char* b) { stage = std::string(b); ++ event_counter; value = a; };
|
||||||
config.set_deserialize("fill_density", "0");
|
config.set_deserialize("fill_density", "0");
|
||||||
|
|
||||||
WHEN("make_perimeters() is called") {
|
WHEN("make_perimeters() is called") {
|
||||||
|
@ -43,11 +43,10 @@ SCENARIO("PrintObject: Perimeter generation", "[PrintObject]") {
|
||||||
SCENARIO("Print: Skirt generation", "[Print]") {
|
SCENARIO("Print: Skirt generation", "[Print]") {
|
||||||
GIVEN("20mm cube and default config") {
|
GIVEN("20mm cube and default config") {
|
||||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||||
TestMesh m { TestMesh::cube_20x20x20 };
|
TestMesh m = TestMesh::cube_20x20x20;
|
||||||
Slic3r::Model model;
|
Slic3r::Model model;
|
||||||
auto event_counter {0U};
|
|
||||||
std::string stage;
|
std::string stage;
|
||||||
int value {0};
|
int value = 0;
|
||||||
config.opt_int("skirt_height") = 1;
|
config.opt_int("skirt_height") = 1;
|
||||||
config.opt_float("skirt_distance") = 1.f;
|
config.opt_float("skirt_distance") = 1.f;
|
||||||
WHEN("Skirts is set to 2 loops") {
|
WHEN("Skirts is set to 2 loops") {
|
||||||
|
@ -78,13 +77,12 @@ void test_is_solid_infill(std::shared_ptr<Slic3r::Print> p, size_t obj_id, size_
|
||||||
SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces to become internal.", "[Print]") {
|
SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces to become internal.", "[Print]") {
|
||||||
GIVEN("sliced 20mm cube and config with top_solid_surfaces = 2 and bottom_solid_surfaces = 1") {
|
GIVEN("sliced 20mm cube and config with top_solid_surfaces = 2 and bottom_solid_surfaces = 1") {
|
||||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||||
TestMesh m { TestMesh::cube_20x20x20 };
|
TestMesh m = TestMesh::cube_20x20x20;
|
||||||
config.opt_int("top_solid_layers") = 2;
|
config.opt_int("top_solid_layers") = 2;
|
||||||
config.opt_int("bottom_solid_layers") = 1;
|
config.opt_int("bottom_solid_layers") = 1;
|
||||||
config.opt_float("layer_height") = 0.5; // get a known number of layers
|
config.opt_float("layer_height") = 0.5; // get a known number of layers
|
||||||
config.set_deserialize("first_layer_height", "0.5");
|
config.set_deserialize("first_layer_height", "0.5");
|
||||||
Slic3r::Model model;
|
Slic3r::Model model;
|
||||||
auto event_counter {0U};
|
|
||||||
std::string stage;
|
std::string stage;
|
||||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||||
print->process();
|
print->process();
|
||||||
|
@ -112,11 +110,10 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
|
||||||
SCENARIO("Print: Brim generation", "[Print]") {
|
SCENARIO("Print: Brim generation", "[Print]") {
|
||||||
GIVEN("20mm cube and default config, 1mm first layer width") {
|
GIVEN("20mm cube and default config, 1mm first layer width") {
|
||||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||||
TestMesh m { TestMesh::cube_20x20x20 };
|
TestMesh m = TestMesh::cube_20x20x20;
|
||||||
Slic3r::Model model;
|
Slic3r::Model model;
|
||||||
auto event_counter {0U};
|
|
||||||
std::string stage;
|
std::string stage;
|
||||||
int value {0};
|
int value = 0;
|
||||||
config.set_deserialize("first_layer_extrusion_width", "1");
|
config.set_deserialize("first_layer_extrusion_width", "1");
|
||||||
WHEN("Brim is set to 3mm") {
|
WHEN("Brim is set to 3mm") {
|
||||||
config.opt_float("brim_width") = 3;
|
config.opt_float("brim_width") = 3;
|
||||||
|
|
|
@ -73,11 +73,10 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
|
||||||
REQUIRE(std::regex_search(gcode, has_match, skirt_regex));
|
REQUIRE(std::regex_search(gcode, has_match, skirt_regex));
|
||||||
}
|
}
|
||||||
THEN("final Z height is 20mm") {
|
THEN("final Z height is 20mm") {
|
||||||
double final_z {0.0};
|
double final_z = 0.0;
|
||||||
auto reader {GCodeReader()};
|
GCodeReader reader;
|
||||||
reader.apply_config(print->config());
|
reader.apply_config(print->config());
|
||||||
reader.parse_buffer(gcode, [&final_z] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
reader.parse_buffer(gcode, [&final_z] (GCodeReader& self, const GCodeReader::GCodeLine& line) {
|
||||||
{
|
|
||||||
final_z = std::max<double>(final_z, static_cast<double>(self.z())); // record the highest Z point we reach
|
final_z = std::max<double>(final_z, static_cast<double>(self.z())); // record the highest Z point we reach
|
||||||
});
|
});
|
||||||
REQUIRE(final_z == Approx(20.));
|
REQUIRE(final_z == Approx(20.));
|
||||||
|
@ -114,22 +113,20 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
|
||||||
REQUIRE(gcode.find("; between-object-gcode") != std::string::npos);
|
REQUIRE(gcode.find("; between-object-gcode") != std::string::npos);
|
||||||
}
|
}
|
||||||
THEN("final Z height is 20.1mm") {
|
THEN("final Z height is 20.1mm") {
|
||||||
double final_z {0.0};
|
double final_z = 0.0;
|
||||||
auto reader {GCodeReader()};
|
GCodeReader reader;
|
||||||
reader.apply_config(print->config());
|
reader.apply_config(print->config());
|
||||||
reader.parse_buffer(gcode, [&final_z] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
reader.parse_buffer(gcode, [&final_z] (GCodeReader& self, const GCodeReader::GCodeLine& line) {
|
||||||
{
|
|
||||||
final_z = std::max(final_z, static_cast<double>(self.z())); // record the highest Z point we reach
|
final_z = std::max(final_z, static_cast<double>(self.z())); // record the highest Z point we reach
|
||||||
});
|
});
|
||||||
REQUIRE(final_z == Approx(20.1));
|
REQUIRE(final_z == Approx(20.1));
|
||||||
}
|
}
|
||||||
THEN("Z height resets on object change") {
|
THEN("Z height resets on object change") {
|
||||||
double final_z {0.0};
|
double final_z = 0.0;
|
||||||
bool reset {false};
|
bool reset = false;
|
||||||
auto reader {GCodeReader()};
|
GCodeReader reader;
|
||||||
reader.apply_config(print->config());
|
reader.apply_config(print->config());
|
||||||
reader.parse_buffer(gcode, [&final_z, &reset] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
reader.parse_buffer(gcode, [&final_z, &reset] (GCodeReader& self, const GCodeReader::GCodeLine& line) {
|
||||||
{
|
|
||||||
if (final_z > 0 && std::abs(self.z() - 0.3) < 0.01 ) { // saw higher Z before this, now it's lower
|
if (final_z > 0 && std::abs(self.z() - 0.3) < 0.01 ) { // saw higher Z before this, now it's lower
|
||||||
reset = true;
|
reset = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,12 +136,11 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
|
||||||
REQUIRE(reset == true);
|
REQUIRE(reset == true);
|
||||||
}
|
}
|
||||||
THEN("Shorter object is printed before taller object.") {
|
THEN("Shorter object is printed before taller object.") {
|
||||||
double final_z {0.0};
|
double final_z = 0.0;
|
||||||
bool reset {false};
|
bool reset = false;
|
||||||
auto reader {GCodeReader()};
|
GCodeReader reader;
|
||||||
reader.apply_config(print->config());
|
reader.apply_config(print->config());
|
||||||
reader.parse_buffer(gcode, [&final_z, &reset] (GCodeReader& self, const GCodeReader::GCodeLine& line)
|
reader.parse_buffer(gcode, [&final_z, &reset] (GCodeReader& self, const GCodeReader::GCodeLine& line) {
|
||||||
{
|
|
||||||
if (final_z > 0 && std::abs(self.z() - 0.3) < 0.01 ) {
|
if (final_z > 0 && std::abs(self.z() - 0.3) < 0.01 ) {
|
||||||
reset = (final_z > 20.0);
|
reset = (final_z > 20.0);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue