summaryrefslogtreecommitdiff
path: root/gerber/tests
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-13 09:37:27 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-13 09:37:27 -0500
commit5e23d07bcb5103b4607c6ad591a2a547c97ee1f6 (patch)
treefdc7989cc6d4fe200d61267b6b9c228dcce44c2c /gerber/tests
parent8f69c1dfa281b6486c8fce16c1d58acef70c7ae7 (diff)
downloadgerbonara-5e23d07bcb5103b4607c6ad591a2a547c97ee1f6.tar.gz
gerbonara-5e23d07bcb5103b4607c6ad591a2a547c97ee1f6.tar.bz2
gerbonara-5e23d07bcb5103b4607c6ad591a2a547c97ee1f6.zip
Fix rendering for line with rectangular aperture per #12. Still need to do the same for arcs.
Diffstat (limited to 'gerber/tests')
-rw-r--r--gerber/tests/test_primitives.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/gerber/tests/test_primitives.py b/gerber/tests/test_primitives.py
index 912cebb..877823d 100644
--- a/gerber/tests/test_primitives.py
+++ b/gerber/tests/test_primitives.py
@@ -27,17 +27,30 @@ def test_line_angle():
line_angle = (l.angle + 2 * math.pi) % (2 * math.pi)
assert_almost_equal(line_angle, expected)
-# Need to update bounds calculation using aperture
-#def test_line_bounds():
-# """ Test Line primitive bounding box calculation
-# """
-# cases = [((0, 0), (1, 1), ((0, 1), (0, 1))),
-# ((-1, -1), (1, 1), ((-1, 1), (-1, 1))),
-# ((1, 1), (-1, -1), ((-1, 1), (-1, 1))),
-# ((-1, 1), (1, -1), ((-1, 1), (-1, 1))),]
-# for start, end, expected in cases:
-# l = Line(start, end, 0)
-# assert_equal(l.bounding_box, expected)
+def test_line_bounds():
+ """ Test Line primitive bounding box calculation
+ """
+ cases = [((0, 0), (1, 1), ((-1, 2), (-1, 2))),
+ ((-1, -1), (1, 1), ((-2, 2), (-2, 2))),
+ ((1, 1), (-1, -1), ((-2, 2), (-2, 2))),
+ ((-1, 1), (1, -1), ((-2, 2), (-2, 2))),]
+
+ c = Circle((0, 0), 2)
+ r = Rectangle((0, 0), 2, 2)
+ for shape in (c, r):
+ for start, end, expected in cases:
+ l = Line(start, end, shape)
+ assert_equal(l.bounding_box, expected)
+ # Test a non-square rectangle
+ r = Rectangle((0, 0), 3, 2)
+ cases = [((0, 0), (1, 1), ((-1.5, 2.5), (-1, 2))),
+ ((-1, -1), (1, 1), ((-2.5, 2.5), (-2, 2))),
+ ((1, 1), (-1, -1), ((-2.5, 2.5), (-2, 2))),
+ ((-1, 1), (1, -1), ((-2.5, 2.5), (-2, 2))),]
+ for start, end, expected in cases:
+ l = Line(start, end, r)
+ assert_equal(l.bounding_box, expected)
+
def test_arc_radius():