| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 |
- import unittest
- from flatcamParsers.ParseExcellon import Excellon
- from flatcamParsers.ParseGerber import Gerber
- class ExcellonNumberParseTestInch(unittest.TestCase):
- # Inch base format: 00.0000
- # LEADING ZEROS
- # With leading zeros, when you type in a coordinate,
- # the leading zeros must always be included. Trailing zeros
- # are unneeded and may be left off. The CNC-7 will automatically add them.
- # TRAILING ZEROS
- # You must show all zeros to the right of the number and can omit
- # all zeros to the left of the number. The CNC-7 will count the number
- # of digits you typed and automatically fill in the missing zeros.
- def test_inch_leading_6digit(self):
- excellon = Excellon()
- self.assertEqual(excellon.zeros, "L")
- self.assertEqual(excellon.parse_number("123456"), 12.3456)
- def test_inch_leading_5digit(self):
- excellon = Excellon()
- self.assertEqual(excellon.parse_number("12345"), 12.345)
- def test_inch_leading_15digit(self):
- excellon = Excellon()
- self.assertEqual(excellon.parse_number("012345"), 1.2345)
- def test_inch_leading_51digit(self):
- excellon = Excellon()
- self.assertEqual(excellon.parse_number("123450"), 12.345)
- def test_inch_trailing_6digit(self):
- excellon = Excellon()
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("123456"), 12.3456)
- def test_inch_trailing_5digit(self):
- excellon = Excellon()
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("12345"), 1.2345)
- def test_inch_trailing_15digit(self):
- excellon = Excellon()
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("012345"), 1.2345)
- def test_inch_trailing_51digit(self):
- excellon = Excellon()
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("123450"), 12.345)
- class ExcellonNumberParseTestMetric(unittest.TestCase):
- # Metric base format: 000.000
- # LEADING ZEROS
- # With leading zeros, when you type in a coordinate,
- # the leading zeros must always be included. Trailing zeros
- # are unneeded and may be left off. The CNC-7 will automatically add them.
- # TRAILING ZEROS
- # You must show all zeros to the right of the number and can omit
- # all zeros to the left of the number. The CNC-7 will count the number
- # of digits you typed and automatically fill in the missing zeros.
- def test_inch_leading_6digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- self.assertEqual(excellon.parse_number("123456"), 123.456)
- def test_inch_leading_5digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- self.assertEqual(excellon.parse_number("12345"), 123.45)
- def test_inch_leading_15digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- self.assertEqual(excellon.parse_number("012345"), 12.345)
- def test_inch_leading_51digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- self.assertEqual(excellon.parse_number("123450"), 123.45)
- def test_inch_trailing_6digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("123456"), 123.456)
- def test_inch_trailing_5digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("12345"), 12.345)
- def test_inch_trailing_15digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("012345"), 12.345)
- def test_inch_trailing_51digit(self):
- excellon = Excellon()
- excellon.units = "mm"
- excellon.zeros = "T"
- self.assertEqual(excellon.parse_number("123450"), 123.45)
- class ExcellonFormatM72Test(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- M72
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "in")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (90.0, 11.75))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (30.25, 10.5))
- class ExcellonFormatM71Test(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- M71
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "mm")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (900.0, 117.5))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (302.5, 105.0))
- class ExcellonFormatINCHLZTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- INCH,LZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "in")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (90.0, 11.75))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (30.25, 10.5))
- class ExcellonFormatINCHTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- INCH,LZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "in")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (90.0, 11.75))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (30.25, 10.5))
- class ExcellonFormatINCHTZTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- INCH,TZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "in")
- self.assertEqual(self.excellon.zeros, "T")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (0.9, 1.175))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (3.025, 1.05))
- class ExcellonFormatMETRICLZTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- METRIC,LZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "mm")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (900.0, 117.5))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (302.5, 105.0))
- class ExcellonFormatMETRICTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- METRIC,LZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "mm")
- self.assertEqual(self.excellon.zeros, "L")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (900.0, 117.5))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (302.5, 105.0))
- class ExcellonFormatMETRICTZTest(unittest.TestCase):
- def setUp(self):
- self.excellon = Excellon()
- code = """
- M48
- METRIC,TZ
- T1C.02362F197S550
- T2C.03543F197S550
- M95
- T1
- X9000Y11750
- X30250Y10500
- """
- code = code.split('\n')
- self.excellon.parse_lines(code)
- def test_format(self):
- self.assertEqual(self.excellon.units.lower(), "mm")
- self.assertEqual(self.excellon.zeros, "T")
- def test_coords(self):
- # For X9000 add the missing 00 on the right. Then divide by 10000.
- self.assertEqual(self.excellon.drills[0]["point"].coords[0], (9.0, 11.75))
- self.assertEqual(self.excellon.drills[1]["point"].coords[0], (30.25, 10.5))
- if __name__ == '__main__':
- unittest.main()
|