test_gcodewriter.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include <catch2/catch.hpp>
  2. #include <memory>
  3. #include "libslic3r/GCode/GCodeWriter.hpp"
  4. using namespace Slic3r;
  5. SCENARIO("set_speed emits values with fixed-point output.", "[GCodeWriter]") {
  6. GIVEN("GCodeWriter instance") {
  7. GCodeWriter writer;
  8. WHEN("set_speed is called to set speed to 99999.123") {
  9. THEN("Output string is G1 F99999.123") {
  10. REQUIRE_THAT(writer.set_speed(99999.123), Catch::Equals("G1 F99999.123\n"));
  11. }
  12. }
  13. WHEN("set_speed is called to set speed to 1") {
  14. THEN("Output string is G1 F1") {
  15. REQUIRE_THAT(writer.set_speed(1.0), Catch::Equals("G1 F1\n"));
  16. }
  17. }
  18. WHEN("set_speed is called to set speed to 203.200022") {
  19. THEN("Output string is G1 F203.2") {
  20. REQUIRE_THAT(writer.set_speed(203.200022), Catch::Equals("G1 F203.2\n"));
  21. }
  22. }
  23. WHEN("set_speed is called to set speed to 203.200522") {
  24. THEN("Output string is G1 F203.201") {
  25. REQUIRE_THAT(writer.set_speed(203.200522), Catch::Equals("G1 F203.201\n"));
  26. }
  27. }
  28. }
  29. }