diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5f2c0cb1f..69dea5efb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -303,6 +303,7 @@ set(SLIC3R_TEST_SOURCES ${TESTDIR}/libslic3r/test_fill.cpp ${TESTDIR}/libslic3r/test_flow.cpp ${TESTDIR}/libslic3r/test_gcodewriter.cpp + ${TESTDIR}/libslic3r/test_gcode.cpp ${TESTDIR}/libslic3r/test_geometry.cpp ${TESTDIR}/libslic3r/test_log.cpp ${TESTDIR}/libslic3r/test_model.cpp @@ -544,6 +545,7 @@ if (SLIC3R_BUILD_TESTS) endif() configure_file("${TESTDIR}/test_options.hpp.in" "${TESTDIR}/test_options.hpp") add_executable(slic3r_test ${SLIC3R_TEST_SOURCES}) + target_compile_options(slic3r_test PUBLIC -DSLIC3R_TEST) add_test(NAME TestSlic3r COMMAND slic3r_test) target_compile_features(slic3r_test PUBLIC cxx_std_14) target_include_directories(slic3r_test PUBLIC cxx_std_14 ${SLIC3R_INCLUDES}) diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.cpp b/xs/src/libslic3r/GCode/CoolingBuffer.cpp index 786a9a8e4..a9db021b8 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.cpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.cpp @@ -50,7 +50,8 @@ apply_speed_factor(std::string &line, float speed_factor, float min_print_speed) // replace speed in string { std::ostringstream oss; - oss << speed; + oss.precision(3); + oss << std::fixed << speed; line.replace(pos+1, (last_pos-pos), oss.str()); } } diff --git a/xs/src/libslic3r/GCode/CoolingBuffer.hpp b/xs/src/libslic3r/GCode/CoolingBuffer.hpp index c290612ba..a45a2d1b8 100644 --- a/xs/src/libslic3r/GCode/CoolingBuffer.hpp +++ b/xs/src/libslic3r/GCode/CoolingBuffer.hpp @@ -37,6 +37,10 @@ class CoolingBuffer { float _min_print_speed; }; +#ifdef SLIC3R_TEST +void apply_speed_factor(std::string &line, float speed_factor, float min_print_speed); +#endif + } #endif