diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index caff200811..2ef08a0474 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -266,7 +266,6 @@ std::string GCodeExport::getFileHeader( break; default: prefix << ";FLAVOR:" << flavorToString(flavor) << new_line; - prefix << ";TARGET_MACHINE.NAME:" << transliterate(machine_name) << new_line; prefix << ";TIME:" << ((print_time) ? static_cast(*print_time) : 6666) << new_line; if (flavor == EGCodeFlavor::ULTIGCODE) { @@ -309,6 +308,7 @@ std::string GCodeExport::getFileHeader( prefix << ";MAXX:" << INT2MM(total_bounding_box.max.x) << new_line; prefix << ";MAXY:" << INT2MM(total_bounding_box.max.y) << new_line; prefix << ";MAXZ:" << INT2MM(total_bounding_box.max.z) << new_line; + prefix << ";TARGET_MACHINE.NAME:" << transliterate(machine_name) << new_line; } return prefix.str(); diff --git a/tests/GCodeExportTest.cpp b/tests/GCodeExportTest.cpp index 134a48b503..3fb07c9be9 100644 --- a/tests/GCodeExportTest.cpp +++ b/tests/GCodeExportTest.cpp @@ -2,6 +2,7 @@ // CuraEngine is released under the terms of the AGPLv3 or higher #include "gcodeExport.h" // The unit under test. + #include "Application.h" // To set up a slice with settings. #include "RetractionConfig.h" // For extruder switch tests. #include "Slice.h" // To set up a slice with settings. @@ -9,6 +10,7 @@ #include "arcus/MockCommunication.h" // To prevent calls to any missing Communication class. #include "utils/Coord_t.h" #include "utils/Date.h" // To check the Griffin header. + #include // NOLINTBEGIN(*-magic-numbers) @@ -101,12 +103,13 @@ TEST_F(GCodeExportTest, CommentMultiLine) "You can honestly say\n" "You made on that day\n" "A Chilean chinchilla's chin chilly"); - EXPECT_EQ(std::string(";If you catch a chinchilla in Chile\n" - ";And cut off its beard, willy-nilly\n" - ";You can honestly say\n" - ";You made on that day\n" - ";A Chilean chinchilla's chin chilly\n"), - output.str()) + EXPECT_EQ( + std::string(";If you catch a chinchilla in Chile\n" + ";And cut off its beard, willy-nilly\n" + ";You can honestly say\n" + ";You made on that day\n" + ";A Chilean chinchilla's chin chilly\n"), + output.str()) << "Each line must be preceded by a semicolon."; } @@ -115,10 +118,11 @@ TEST_F(GCodeExportTest, CommentMultiple) gcode.writeComment("Thunderbolt and lightning"); gcode.writeComment("Very very frightening me"); gcode.writeComment(" - Galileo (1638)"); - EXPECT_EQ(std::string(";Thunderbolt and lightning\n" - ";Very very frightening me\n" - "; - Galileo (1638)\n"), - output.str()) + EXPECT_EQ( + std::string(";Thunderbolt and lightning\n" + ";Very very frightening me\n" + "; - Galileo (1638)\n"), + output.str()) << "Semicolon before each line, and newline in between."; } @@ -328,9 +332,10 @@ TEST_F(GCodeExportTest, HeaderUltiGCode) std::string result = gcode.getFileHeader(extruder_is_used, &print_time, filament_used); - EXPECT_EQ(result, - ";FLAVOR:UltiGCode\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n;TIME:1337\n;MATERIAL:100\n;MATERIAL2:200\n;NOZZLE_DIAMETER:0.4\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;" - "MAXY:1\n;MAXZ:1\n"); + EXPECT_EQ( + result, + ";FLAVOR:UltiGCode\n;TIME:1337\n;MATERIAL:100\n;MATERIAL2:200\n;NOZZLE_DIAMETER:0.4\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;" + "MAXY:1\n;MAXZ:1\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n"); } TEST_F(GCodeExportTest, HeaderRepRap) @@ -347,9 +352,10 @@ TEST_F(GCodeExportTest, HeaderRepRap) std::string result = gcode.getFileHeader(extruder_is_used, &print_time, filament_used); - EXPECT_EQ(result, - ";FLAVOR:RepRap\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n;TIME:1337\n;Filament used: 0.02m, 0.05m\n;Layer height: " - "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n"); + EXPECT_EQ( + result, + ";FLAVOR:RepRap\n;TIME:1337\n;Filament used: 0.02m, 0.05m\n;Layer height: " + "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n"); } TEST_F(GCodeExportTest, HeaderMarlin) @@ -366,9 +372,10 @@ TEST_F(GCodeExportTest, HeaderMarlin) std::string result = gcode.getFileHeader(extruder_is_used, &print_time, filament_used); - EXPECT_EQ(result, - ";FLAVOR:Marlin\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n;TIME:1337\n;Filament used: 0.02m, 0.05m\n;Layer height: " - "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n"); + EXPECT_EQ( + result, + ";FLAVOR:Marlin\n;TIME:1337\n;Filament used: 0.02m, 0.05m\n;Layer height: " + "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n"); } TEST_F(GCodeExportTest, HeaderMarlinVolumetric) @@ -383,9 +390,10 @@ TEST_F(GCodeExportTest, HeaderMarlinVolumetric) std::string result = gcode.getFileHeader(extruder_is_used, &print_time, filament_used); - EXPECT_EQ(result, - ";FLAVOR:Marlin(Volumetric)\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n;TIME:1337\n;Filament used: 100mm3, 200mm3\n;Layer height: " - "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n"); + EXPECT_EQ( + result, + ";FLAVOR:Marlin(Volumetric)\n;TIME:1337\n;Filament used: 100mm3, 200mm3\n;Layer height: " + "0.123\n;MINX:0\n;MINY:0\n;MINZ:0\n;MAXX:1\n;MAXY:1\n;MAXZ:1\n;TARGET_MACHINE.NAME:Your favourite 3D printer\n"); } /* @@ -405,8 +413,9 @@ TEST_F(GCodeExportTest, EVsMmVolumetric) "area of the filament to convert the volume to a length."; constexpr double mm_input = 33.0; - EXPECT_EQ(gcode.mmToE(mm_input), mm_input * filament_area) << "Since the input mm is linear but the E output must be volumetric, we need to multiply by the cross-sectional area to convert " - "length to volume."; + EXPECT_EQ(gcode.mmToE(mm_input), mm_input * filament_area) + << "Since the input mm is linear but the E output must be volumetric, we need to multiply by the cross-sectional area to convert " + "length to volume."; constexpr double e_input = 100.0; EXPECT_EQ(gcode.eToMm3(e_input, 0), e_input) << "Since the E is volumetric and mm3 is also volumetric, the output needs to be the same."; @@ -431,8 +440,9 @@ TEST_F(GCodeExportTest, EVsMmLinear) } constexpr double mm3_input = 33.0; - EXPECT_EQ(gcode.mm3ToE(mm3_input), mm3_input / filament_area) << "Since the input mm3 is volumetric but the E output must be linear, we need to divide by the cross-sectional area to convert " - "volume to length."; + EXPECT_EQ(gcode.mm3ToE(mm3_input), mm3_input / filament_area) + << "Since the input mm3 is volumetric but the E output must be linear, we need to divide by the cross-sectional area to convert " + "volume to length."; constexpr double e_input = 100.0; EXPECT_EQ(gcode.eToMm3(e_input, 0), e_input * filament_area) << "Since the input E is linear but the output must be volumetric, we " @@ -492,7 +502,7 @@ TEST_F(GCodeExportTest, WriteZHopStartCustomSpeed) Application::getInstance().current_slice->scene.extruders[gcode.current_extruder].settings.add("speed_z_hop", "1"); // 60mm/min. gcode.current_layer_z = 2000; constexpr coord_t hop_height = 3000; - constexpr Velocity speed { 4.0 }; // 240 mm/min. + constexpr Velocity speed{ 4.0 }; // 240 mm/min. gcode.writeZhopStart(hop_height, speed); EXPECT_EQ(std::string("G1 F240 Z5\n"), output.str()) << "Custom provided speed should be used."; } @@ -520,7 +530,7 @@ TEST_F(GCodeExportTest, WriteZHopEndCustomSpeed) Application::getInstance().current_slice->scene.extruders[gcode.current_extruder].settings.add("speed_z_hop", "1"); gcode.current_layer_z = 2000; gcode.is_z_hopped = 3000; - constexpr Velocity speed { 4.0 }; // 240 mm/min. + constexpr Velocity speed{ 4.0 }; // 240 mm/min. gcode.writeZhopEnd(speed); EXPECT_EQ(std::string("G1 F240 Z2\n"), output.str()) << "Custom provided speed should be used."; }