summaryrefslogtreecommitdiff
path: root/gerber/tests/test_primitives.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-09-10 15:54:29 -0400
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-09-10 15:54:29 -0400
commitb81c9d4bf96845ced3495eb158ec3a3c9e4dce3d (patch)
treeab939229a9735a4c0fd831daf0a11151d3c78d0a /gerber/tests/test_primitives.py
parentc92d2d9ea2853fd22b5ff51f211b03b4e660c551 (diff)
parentcb2fa34e881a389cf8a4bc98fd12be662ff687f8 (diff)
downloadgerbonara-b81c9d4bf96845ced3495eb158ec3a3c9e4dce3d.tar.gz
gerbonara-b81c9d4bf96845ced3495eb158ec3a3c9e4dce3d.tar.bz2
gerbonara-b81c9d4bf96845ced3495eb158ec3a3c9e4dce3d.zip
Merge pull request #40 from curtacircuitos/cairo-render-unification
Cairo render unification
Diffstat (limited to 'gerber/tests/test_primitives.py')
-rw-r--r--gerber/tests/test_primitives.py34
1 files changed, 14 insertions, 20 deletions
diff --git a/gerber/tests/test_primitives.py b/gerber/tests/test_primitives.py
index 67c7822..f8a32da 100644
--- a/gerber/tests/test_primitives.py
+++ b/gerber/tests/test_primitives.py
@@ -4,6 +4,7 @@
# Author: Hamilton Kibbe <ham@hamiltonkib.be>
from ..primitives import *
from .tests import *
+from operator import add
def test_primitive_smoketest():
@@ -766,38 +767,31 @@ def test_polygon_offset():
def test_region_ctor():
""" Test Region creation
"""
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
- for i, point in enumerate(points):
- assert_array_almost_equal(r.points[i], point)
+ r = Region(lines)
+ for i, p in enumerate(lines):
+ assert_equal(r.primitives[i], p)
def test_region_bounds():
""" Test region bounding box calculation
"""
- points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
+ r = Region(lines)
xbounds, ybounds = r.bounding_box
assert_array_almost_equal(xbounds, (0, 1))
assert_array_almost_equal(ybounds, (0, 1))
-def test_region_conversion():
- points = ((2.54, 25.4), (254.0,2540.0), (25400.0,254000.0), (2.54,25.4))
- r = Region(points, units='metric')
- r.to_inch()
- assert_equal(set(r.points), {(0.1, 1.0), (10.0, 100.0), (1000.0, 10000.0)})
-
- points = ((0.1, 1.0), (10.0, 100.0), (1000.0, 10000.0), (0.1, 1.0))
- r = Region(points, units='inch')
- r.to_metric()
- assert_equal(set(r.points), {(2.54, 25.4), (254.0, 2540.0), (25400.0, 254000.0)})
def test_region_offset():
- points = ((0, 0), (1,0), (1,1), (0,1))
- r = Region(points)
- r.offset(1, 0)
- assert_equal(set(r.points), {(1, 0), (2, 0), (2,1), (1, 1)})
+ apt = Circle((0,0), 0)
+ lines = (Line((0,0), (1,0), apt), Line((1,0), (1,1), apt), Line((1,1), (0,1), apt), Line((0,1), (0,0), apt))
+ r = Region(lines)
+ xlim, ylim = r.bounding_box
r.offset(0, 1)
- assert_equal(set(r.points), {(1, 1), (2, 1), (2,2), (1, 2)})
+ assert_array_almost_equal((xlim, tuple([y+1 for y in ylim])), r.bounding_box)
def test_round_butterfly_ctor():
""" Test round butterfly creation