test_gcode.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "../test/unit_tests.h"
  23. #include <src/gcode/gcode.h>
  24. #include <src/gcode/parser.h>
  25. MARLIN_TEST(gcode, process_parsed_command) {
  26. GcodeSuite suite;
  27. parser.command_letter = 'G';
  28. parser.codenum = 0;
  29. suite.process_parsed_command(false);
  30. }
  31. MARLIN_TEST(gcode, parse_g1_xz) {
  32. char current_command[] = "G0 X10 Z30";
  33. parser.command_letter = -128;
  34. parser.codenum = -1;
  35. parser.parse(current_command);
  36. TEST_ASSERT_EQUAL('G', parser.command_letter);
  37. TEST_ASSERT_EQUAL(0, parser.codenum);
  38. TEST_ASSERT_TRUE(parser.seen('X'));
  39. TEST_ASSERT_FALSE(parser.seen('Y'));
  40. TEST_ASSERT_TRUE(parser.seen('Z'));
  41. TEST_ASSERT_FALSE(parser.seen('E'));
  42. }
  43. MARLIN_TEST(gcode, parse_g1_nxz) {
  44. char current_command[] = "N123 G0 X10 Z30";
  45. parser.command_letter = -128;
  46. parser.codenum = -1;
  47. parser.parse(current_command);
  48. TEST_ASSERT_EQUAL('G', parser.command_letter);
  49. TEST_ASSERT_EQUAL(0, parser.codenum);
  50. TEST_ASSERT_TRUE(parser.seen('X'));
  51. TEST_ASSERT_FALSE(parser.seen('Y'));
  52. TEST_ASSERT_TRUE(parser.seen('Z'));
  53. TEST_ASSERT_FALSE(parser.seen('E'));
  54. }