def test_parameterItems_empty_string(self): """Test parameterItems when provided an empty string.""" unit = GcodeParser() self.assertIsNone(unit.parameters, "The parameters should be None.") result = [item for item in unit.parameterItems("")] self.assertEqual(result, [], "An empty list should be generated.")
def test_parameterItems_none(self): """Test parameterItems when the parameters attribute is None.""" unit = GcodeParser() self.assertIsNone(unit.parameters, "The parameters should be None.") result = [item for item in unit.parameterItems()] self.assertEqual(result, [], "An empty list should be generated.")
def test_parameterItems_whitespace_labels_and_values(self): """Test that parameterItems permits whitespace between labels and values.""" unit = GcodeParser() self.assertIsNone(unit.parameters, "The parameters should be None.") result = [item for item in unit.parameterItems("A 1 B C 2")] self.assertEqual( result, [("A", 1), ("B", None), ("C", 2), ("", "B C 2")], "The expected result should be generated." )
def test_parameterItems_nonAlphaFirstChar(self): """Test parameterItems when the first character is non-alphabetic.""" unit = GcodeParser() self.assertIsNone(unit.parameters, "The parameters should be None.") result = [item for item in unit.parameterItems("12 A2")] self.assertEqual( result, [("A", 2), ("", "12 A2")], "The expected result should be generated." )
def test_parameterItems_custom_string(self): """Test that parameterItems parses the given string when one is given.""" unit = GcodeParser() self.assertIsNone(unit.parameters, "The parameters should be None.") result = [item for item in unit.parameterItems("A1BC2")] self.assertEqual( result, [("A", 1), ("B", None), ("C", 2), ("", "BC2")], "The expected result should be generated." )
def test_parameterItems_no_string_given(self): """Test that parameterItems uses the parameters property when no string is given.""" unit = GcodeParser() unit.parse("G1 A1BC2") self.assertEqual(unit.parameters, "A1BC2", "The parameters should be 'A1BC2'.") result = [item for item in unit.parameterItems()] self.assertEqual( result, [("A", 1), ("B", None), ("C", 2), ("", "BC2")], "The expected result should be generated." )