diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-01-14 14:33:00 -0200 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2015-01-14 14:33:00 -0200 |
commit | 137c73f3e42281de67bde8f1c0b16938f5b8aeeb (patch) | |
tree | 1c3140276d1f1b0cd16aec36d89cac183bf059d6 /gerber/tests | |
parent | ac89a3c36505bebff68305eb8e315482cba860fd (diff) | |
download | gerbonara-137c73f3e42281de67bde8f1c0b16938f5b8aeeb.tar.gz gerbonara-137c73f3e42281de67bde8f1c0b16938f5b8aeeb.tar.bz2 gerbonara-137c73f3e42281de67bde8f1c0b16938f5b8aeeb.zip |
Many additions to Excellon parsing/creation.
CAUTION: the original code used zero_suppression flags
in the opposite sense as Gerber functions. This
patch changes it to behave just like Gerber code.
* Add metric/inch conversion support
* Add settings context variable to to_gerber just like Gerber code.
* Add some missing Excellon values.
Tests are not entirely updated.
Diffstat (limited to 'gerber/tests')
-rw-r--r-- | gerber/tests/test_excellon_statements.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/gerber/tests/test_excellon_statements.py b/gerber/tests/test_excellon_statements.py index 0e1efa6..13733f8 100644 --- a/gerber/tests/test_excellon_statements.py +++ b/gerber/tests/test_excellon_statements.py @@ -68,18 +68,31 @@ def test_toolselection_dump(): def test_coordinatestmt_factory(): """ Test CoordinateStmt factory method """ + settings = FileSettings(format=(2, 5), zero_suppression='trailing', + units='inch', notation='absolute') + line = 'X0278207Y0065293' - stmt = CoordinateStmt.from_excellon(line) + stmt = CoordinateStmt.from_excellon(line, settings) assert_equal(stmt.x, 2.78207) assert_equal(stmt.y, 0.65293) - line = 'X02945' - stmt = CoordinateStmt.from_excellon(line) - assert_equal(stmt.x, 2.945) + # line = 'X02945' + # stmt = CoordinateStmt.from_excellon(line) + # assert_equal(stmt.x, 2.945) + + # line = 'Y00575' + # stmt = CoordinateStmt.from_excellon(line) + # assert_equal(stmt.y, 0.575) + + settings = FileSettings(format=(2, 4), zero_suppression='leading', + units='inch', notation='absolute') + + line = 'X9660Y4639' + stmt = CoordinateStmt.from_excellon(line, settings) + assert_equal(stmt.x, 0.9660) + assert_equal(stmt.y, 0.4639) + assert_equal(stmt.to_excellon(settings), "X9660Y4639") - line = 'Y00575' - stmt = CoordinateStmt.from_excellon(line) - assert_equal(stmt.y, 0.575) def test_coordinatestmt_dump(): @@ -88,9 +101,13 @@ def test_coordinatestmt_dump(): lines = ['X0278207Y0065293', 'X0243795', 'Y0082528', 'Y0086028', 'X0251295Y0081528', 'X02525Y0078', 'X0255Y00575', 'Y0052', 'X02675', 'Y00575', 'X02425', 'Y0052', 'X023', ] + + settings = FileSettings(format=(2, 4), zero_suppression='leading', + units='inch', notation='absolute') + for line in lines: - stmt = CoordinateStmt.from_excellon(line) - assert_equal(stmt.to_excellon(), line) + stmt = CoordinateStmt.from_excellon(line, settings) + assert_equal(stmt.to_excellon(settings), line) def test_commentstmt_factory(): |