def test_gcode_setter_subCode(self):
        """Test the gcode setter when supplied with a subcode."""
        unit = GcodeParser()

        unit.gcode = "G1.2"

        self.assertEqual(unit.type, "G", "The type should be 'G'.")
        self.assertEqual(unit.code, 1, "The code should be 1.")
        self.assertEqual(unit.subCode, 2, "The subCode should be 2.")
        self.assertEqual(unit.gcode, "G1", "The gcode should be 'G1'.")
        self.assertEqual(unit.commandString, "G1.2", "The commandString should be 'G1.2'.")

        unit.gcode = "M17.1"

        self.assertEqual(unit.type, "M", "The type should be 'M'.")
        self.assertEqual(unit.code, 17, "The code should be 17.")
        self.assertEqual(unit.subCode, 1, "The subCode should be 1.")
        self.assertEqual(unit.gcode, "M17", "The gcode should be 'M17'.")
        self.assertEqual(unit.commandString, "M17.1", "The commandString should be 'M17.1'.")

        # T codes don't support subCodes
        with self.assertRaises(ValueError):
            unit.gcode = "T2.3"

        # No side-effects from exception
        self.assertEqual(unit.type, "M", "The type should be 'M'.")
        self.assertEqual(unit.code, 17, "The code should be 17.")
        self.assertEqual(unit.subCode, 1, "The subCode should be 1.")
    def test_gcode_setter_noSubCode(self):
        """Test the gcode setter when no subCode is supplied."""
        unit = GcodeParser()

        unit.gcode = "G0"

        self.assertEqual(unit.type, "G", "The type should be 'G'.")
        self.assertEqual(unit.code, 0, "The code should be 0.")
        self.assertIsNone(unit.subCode, "The subCode should be None.")
        self.assertEqual(unit.gcode, "G0", "The gcode should be 'G0'.")
        self.assertEqual(unit.commandString, "G0", "The commandString should be 'G0'.")

        unit.gcode = "M17"

        self.assertEqual(unit.type, "M", "The type should be 'M'.")
        self.assertEqual(unit.code, 17, "The code should be 17.")
        self.assertIsNone(unit.subCode, "The subCode should be None.")
        self.assertEqual(unit.gcode, "M17", "The gcode should be 'M17'.")
        self.assertEqual(unit.commandString, "M17", "The commandString should be 'M17'.")

        unit.gcode = "T2"

        self.assertEqual(unit.type, "T", "The type should be 'T'.")
        self.assertEqual(unit.code, 2, "The code should be 2.")
        self.assertEqual(unit.gcode, "T2", "The gcode should be 'T2'.")
        self.assertIsNone(unit.subCode, "The subCode should be None.")
        self.assertEqual(unit.commandString, "T2", "The commandString should be 'T2'.")
    def test_gcode_setter_whitespace(self):
        """Test the gcode setter when the supplied value has leading/trailing whitespace."""
        unit = GcodeParser()

        unit.gcode = "  G  1  "

        self.assertEqual(unit.type, "G", "The type should be 'G'.")
        self.assertEqual(unit.code, 1, "The code should be 1.")
        self.assertIsNone(unit.subCode, "The subCode should be None.")

        unit.gcode = "  M  17.1  "

        self.assertEqual(unit.type, "M", "The type should be 'M'.")
        self.assertEqual(unit.code, 17, "The code should be 17.")
        self.assertEqual(unit.subCode, 1, "The subCode should be 1.")

        unit.gcode = "  T  2  "

        self.assertEqual(unit.type, "T", "The type should be 'T'.")
        self.assertEqual(unit.code, 2, "The code should be 2.")
        self.assertEqual(unit.gcode, "T2", "The gcode should be 'T2'.")