示例#1
0
 def test_ortho_right_squaring_shapes(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(6, 0)
     p3 = IntegerPoint(6, 4)
     p4 = IntegerPoint(0, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     self.assertEqual(len(shapes), 1)
     expectedTriangle = IntegerOrthoRightTriangle(p1, p3, p4)
     self.assertTrue(shapes[0].like(expectedTriangle))
示例#2
0
 def test_common_edge_squaring_shapes_right(self):
     p1 = IntegerPoint(5, 0)
     p2 = IntegerPoint(0, 2)
     p3 = IntegerPoint(5, 4)
     p4 = IntegerPoint(0, 0)
     p5 = IntegerPoint(0, 4)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p4)
     expectedTriangle2 = IntegerTriangle(p2, p3, p5)
     self.assertEqual(len(shapes), 2)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
示例#3
0
 def test_squaring_shapes_no_interior_vertex(self):
     p1 = IntegerPoint(0, 0)
     p2 = IntegerPoint(5, 2)
     p3 = IntegerPoint(2, 5)
     p4 = IntegerPoint(5, 0)
     p5 = IntegerPoint(5, 5)
     p6 = IntegerPoint(0, 5)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p4)
     expectedTriangle2 = IntegerTriangle(p2, p3, p5)
     expectedTriangle3 = IntegerTriangle(p1, p3, p6)
     self.assertEqual(len(shapes), 3)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle3)]), 1)
示例#4
0
 def test_squaring_shapes_upper_right_interior_vertex(self):
     p1 = IntegerPoint(0, 5)
     p2 = IntegerPoint(4, 4)
     p3 = IntegerPoint(6, 0)
     p4 = IntegerPoint(6, 4)
     p5 = IntegerPoint(4, 5)
     p6 = IntegerPoint(0, 0)
     t1 = IntegerTriangle(p1, p2, p3)
     shapes = t1.squaring_shapes()
     expectedTriangle1 = IntegerTriangle(p1, p2, p5)
     expectedTriangle2 = IntegerTriangle(p2, p3, p4)
     expectedTriangle3 = IntegerTriangle(p1, p3, p6)
     expectedRectangle = IntegerOrthoRectangle(p4, p5)
     self.assertEqual(len(shapes), 4)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle1)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle2)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedTriangle3)]), 1)
     self.assertTrue(len([shape for shape in shapes if shape.like(expectedRectangle)]), 1)