Пример #1
0
 def test_str(self):
     tr = Triangle(Point(0, 0), Point(3, 0), Point(0, 3))
     self.assertEqual(str(tr), "0 0 3 0 0 3")
Пример #2
0
    def test_is_rb(self):
        tr = Triangle(Point(0, 0), Point(3, 0), Point(0, 3))
        self.assertTrue(tr.is_rb())

        tr = Triangle(Point(4.5, 4.5), Point(3, 0), Point(0, 3))
        self.assertTrue(tr.is_rb())

        tr = Triangle(Point(0, 0), Point(0, 0), Point(0, 0))
        self.assertFalse(tr.is_rb())

        tr = Triangle(Point(0, 1.23), Point(0, 1.23), Point(0, 6))
        self.assertFalse(tr.is_rb())

        tr = Triangle(Point(0, 1), Point(0, 3), Point(0, 6))
        self.assertFalse(tr.is_rb())
Пример #3
0
    def test_square(self):
        tr = Triangle(Point(0, 1), Point(0, 3), Point(0, 6))
        self.assertEqual(tr.square(), -1)

        tr = Triangle(Point(0, 0), Point(3, 0), Point(0, 3))
        self.assertEqual(tr.square(), 4.5)

        tr = Triangle(Point(0, 0), Point(10.1, 0), Point(0, 10.1))
        self.assertEqual(tr.square(), 51.005)

        tr = Triangle(Point(0, 0), Point(0, 0), Point(0, 0))
        self.assertEqual(tr.square(), -1)

        tr = Triangle(Point(0, 1.23), Point(0, 1.23), Point(0, 6))
        self.assertEqual(tr.square(), -1)

        tr = Triangle(Point(0, 1), Point(0, 3), Point(0, 6))
        self.assertEqual(tr.square(), -1)
Пример #4
0
    def test_is_triangle(self):
        tr = Triangle(Point(0, 0), Point(0, 3), Point(4, 0))
        self.assertTrue(tr.is_triangle())

        tr = Triangle(Point(0, 0), Point(0, 3), Point(10, 0))
        self.assertTrue(tr.is_triangle())

        tr = Triangle(Point(0, 1.5), Point(3, 0), Point(1.5, 1))
        self.assertTrue(tr.is_triangle())

        tr = Triangle(Point(0, 1), Point(0, 3), Point(0, 6))
        self.assertFalse(tr.is_triangle())

        tr = Triangle(Point(0, 1.23), Point(0, 1.23), Point(0, 6))
        self.assertFalse(tr.is_triangle())

        tr = Triangle(Point(0, 0), Point(0, 0), Point(0, 0))
        self.assertFalse(tr.is_triangle())