Beispiel #1
0
class TestQuadrilateral(TestCase):
    def setUp(self) -> None:
        self.q1 = Quadrilateral(5, 5, 2, 5, 1, 0, 4, 0)
        self.q2 = Quadrilateral(5, 5, 2, 5, 1, 0, 4, 0)
        self.q3 = Quadrilateral(5, 5, 2, 5, 1, 0, 4, 1)

    def test_side_lengths(self):
        self.assertEqual(self.q1.side_lengths(),
                         (3.0, math.sqrt(26), 3.0, math.sqrt(26)))  # TODO

    def test_smallest_x(self):
        self.assertEqual(self.q1.smallest_x(), 1)  # TODO

    def test_eq(self):
        self.assertTrue(self.q1.__eq__(self.q2))
        self.assertFalse(self.q1.__eq__(self.q3))
        self.assertFalse(self.q3.__eq__(self.q2))

    def test_ne(self):
        self.assertTrue(self.q1.__ne__(self.q3))
        self.assertTrue(self.q2.__ne__(self.q3))
        self.assertFalse(self.q1.__ne__(self.q2))

    def test_str(self):
        self.assertEqual(self.q1.__str__(), "(5, 5), (2, 5), (1, 0), (4, 0)")
 def test___eq__(self):
     print("Testing __eq__ method")
     A = Quadrilateral(0, 0, -3.5, 0.0, -3.5, -7.8, 0, -7.8)
     B = Quadrilateral(0.0, 0.0, -3.0, 1, -3.0, -2, 0.0, -1.0)
     C = Quadrilateral(0, 0, -1, 0, -1, -1, 0, -1)
     self.assertTrue(A == A)
     self.assertFalse(A == B)
     self.assertTrue(B.__eq__(B))
     self.assertFalse(B.__eq__(C))
     print("Done testing __eq__ method successfully")
Beispiel #3
0
 def test_eq_(self):
     q1 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0)
     q2 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0)
     q3 = Quadrilateral(0, 4, 6, 5, 6, 0, 0, 0)
     self.assertTrue(q1.__eq__(q2))
     self.assertFalse(q1.__eq__(q3))