summaryrefslogtreecommitdiff
path: root/gerber/tests
diff options
context:
space:
mode:
authorPaulo Henrique Silva <ph.silva@gmail.com>2014-11-10 12:24:09 -0200
committerPaulo Henrique Silva <ph.silva@gmail.com>2014-11-10 12:24:09 -0200
commitab69ee0172353e64fbe5099a974341e88feaf24b (patch)
tree13dacd4fc7fceb664d86dae1457d4511ff928181 /gerber/tests
parentf5abd5b0bdc0b9f524456dc9216bd0f3732e82a0 (diff)
downloadgerbonara-ab69ee0172353e64fbe5099a974341e88feaf24b.tar.gz
gerbonara-ab69ee0172353e64fbe5099a974341e88feaf24b.tar.bz2
gerbonara-ab69ee0172353e64fbe5099a974341e88feaf24b.zip
Bunch of small fixes to improve Gerber read/write.
Diffstat (limited to 'gerber/tests')
-rw-r--r--gerber/tests/test_excellon_statements.py6
-rw-r--r--gerber/tests/test_gerber_statements.py8
-rw-r--r--gerber/tests/test_utils.py15
3 files changed, 18 insertions, 11 deletions
diff --git a/gerber/tests/test_excellon_statements.py b/gerber/tests/test_excellon_statements.py
index f2e17ee..0e1efa6 100644
--- a/gerber/tests/test_excellon_statements.py
+++ b/gerber/tests/test_excellon_statements.py
@@ -23,9 +23,9 @@ def test_excellontool_factory():
def test_excellontool_dump():
""" Test ExcellonTool to_excellon()
"""
- exc_lines = ['T1F00S00C0.01200', 'T2F00S00C0.01500', 'T3F00S00C0.01968',
- 'T4F00S00C0.02800', 'T5F00S00C0.03300', 'T6F00S00C0.03800',
- 'T7F00S00C0.04300', 'T8F00S00C0.12500', 'T9F00S00C0.13000', ]
+ exc_lines = ['T1F0S0C0.01200', 'T2F0S0C0.01500', 'T3F0S0C0.01968',
+ 'T4F0S0C0.02800', 'T5F0S0C0.03300', 'T6F0S0C0.03800',
+ 'T7F0S0C0.04300', 'T8F0S0C0.12500', 'T9F0S0C0.13000', ]
settings = FileSettings(format=(2, 5), zero_suppression='trailing',
units='inch', notation='absolute')
for line in exc_lines:
diff --git a/gerber/tests/test_gerber_statements.py b/gerber/tests/test_gerber_statements.py
index a463c9d..62b99b4 100644
--- a/gerber/tests/test_gerber_statements.py
+++ b/gerber/tests/test_gerber_statements.py
@@ -123,7 +123,7 @@ def test_IPParamStmt_dump():
def test_OFParamStmt_factory():
- """ Test OFParamStmt factory
+ """ Test OFParamStmt factory
"""
stmt = {'param': 'OF', 'a': '0.1234567', 'b': '0.1234567'}
of = OFParamStmt.from_dict(stmt)
@@ -139,13 +139,13 @@ def test_OFParamStmt():
assert_equal(stmt.param, param)
assert_equal(stmt.a, val)
assert_equal(stmt.b, val)
-
+
def test_OFParamStmt_dump():
""" Test OFParamStmt to_gerber()
"""
- stmt = {'param': 'OF', 'a': '0.1234567', 'b': '0.1234567'}
+ stmt = {'param': 'OF', 'a': '0.123456', 'b': '0.123456'}
of = OFParamStmt.from_dict(stmt)
- assert_equal(of.to_gerber(), '%OFA0.123456B0.123456*%')
+ assert_equal(of.to_gerber(), '%OFA0.12345B0.12345*%')
def test_LPParamStmt_factory():
diff --git a/gerber/tests/test_utils.py b/gerber/tests/test_utils.py
index 001a32f..706fa65 100644
--- a/gerber/tests/test_utils.py
+++ b/gerber/tests/test_utils.py
@@ -19,7 +19,8 @@ def test_zero_suppression():
('1000', 0.01), ('10000', 0.1), ('100000', 1.0),
('1000000', 10.0), ('-1', -0.00001), ('-10', -0.0001),
('-100', -0.001), ('-1000', -0.01), ('-10000', -0.1),
- ('-100000', -1.0), ('-1000000', -10.0), ]
+ ('-100000', -1.0), ('-1000000', -10.0),
+ ('0', 0.0)]
for string, value in test_cases:
assert(value == parse_gerber_value(string, fmt, zero_suppression))
assert(string == write_gerber_value(value, fmt, zero_suppression))
@@ -30,7 +31,8 @@ def test_zero_suppression():
('00001', 0.001), ('000001', 0.0001),
('0000001', 0.00001), ('-1', -10.0), ('-01', -1.0),
('-001', -0.1), ('-0001', -0.01), ('-00001', -0.001),
- ('-000001', -0.0001), ('-0000001', -0.00001)]
+ ('-000001', -0.0001), ('-0000001', -0.00001),
+ ('0', 0.0)]
for string, value in test_cases:
assert(value == parse_gerber_value(string, fmt, zero_suppression))
assert(string == write_gerber_value(value, fmt, zero_suppression))
@@ -46,7 +48,8 @@ def test_format():
((2, 1), '1', 0.1), ((2, 7), '-1', -0.0000001),
((2, 6), '-1', -0.000001), ((2, 5), '-1', -0.00001),
((2, 4), '-1', -0.0001), ((2, 3), '-1', -0.001),
- ((2, 2), '-1', -0.01), ((2, 1), '-1', -0.1), ]
+ ((2, 2), '-1', -0.01), ((2, 1), '-1', -0.1),
+ ((2, 6), '0', 0) ]
for fmt, string, value in test_cases:
assert(value == parse_gerber_value(string, fmt, zero_suppression))
assert(string == write_gerber_value(value, fmt, zero_suppression))
@@ -57,7 +60,8 @@ def test_format():
((2, 5), '1', 10.0), ((1, 5), '1', 1.0),
((6, 5), '-1', -100000.0), ((5, 5), '-1', -10000.0),
((4, 5), '-1', -1000.0), ((3, 5), '-1', -100.0),
- ((2, 5), '-1', -10.0), ((1, 5), '-1', -1.0), ]
+ ((2, 5), '-1', -10.0), ((1, 5), '-1', -1.0),
+ ((2, 5), '0', 0)]
for fmt, string, value in test_cases:
assert(value == parse_gerber_value(string, fmt, zero_suppression))
assert(string == write_gerber_value(value, fmt, zero_suppression))
@@ -81,3 +85,6 @@ def test_decimal_padding():
assert_equal(decimal_string(value, precision=4, padding=True), '1.1230')
assert_equal(decimal_string(value, precision=5, padding=True), '1.12300')
assert_equal(decimal_string(value, precision=6, padding=True), '1.123000')
+
+ assert_equal(decimal_string(0, precision=6, padding=True), '0.000000')
+