Skip to content

Commit b521d96

Browse files
committed
Add tests for axisall repr and str
* pygorithm/geometry/axisall.py - fix missing self. * tests/test_geometry.py - add tests for axisall repr and str
1 parent b56c063 commit b521d96

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

pygorithm/geometry/axisall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,4 @@ def __str__(self):
222222
if pretty_max == math.floor(pretty_max):
223223
pretty_max = math.floor(pretty_max)
224224

225-
return "axisall(along {} from {} to {})".format(str(axis), pretty_min, pretty_max)
225+
return "axisall(along {} from {} to {})".format(str(self.axis), pretty_min, pretty_max)

tests/test_geometry.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,22 @@ def test_contains_point_inner(self):
545545
outer, inner = axisall.AxisAlignedLine.contains_point(_aal1, 0.75)
546546
self.assertFalse(outer)
547547
self.assertTrue(inner)
548+
549+
def test_repr(self):
550+
_aal = axisall.AxisAlignedLine(self.vec_1_1, 0, 1)
551+
552+
exp = "AxisAlignedLine(axis=vector2(x=1, y=1), min=0, max=1)"
553+
self.assertEqual(exp, repr(_aal))
554+
555+
def test_str(self):
556+
_aal1 = axisall.AxisAlignedLine(self.vec_1_1, 0, 1)
557+
_aal2 = axisall.AxisAlignedLine(self.vec_1_1, 0.707123, 0.707123)
558+
559+
exp1 = "axisall(along <1, 1> from 0 to 1)"
560+
exp2 = "axisall(along <1, 1> from 0.707 to 0.707)"
561+
562+
self.assertEqual(exp1, str(_aal1))
563+
self.assertEqual(exp2, str(_aal2))
548564

549565
class TestPolygon(unittest.TestCase):
550566
def setUp(self):

0 commit comments

Comments
 (0)