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)")
from two_d_point import TwoDPoint from quadrilateral import Quadrilateral from rectangle import Rectangle from square import Square if __name__ == '__main__': point1 = TwoDPoint(3, 2) print(point1.__str__()) q1 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0) print(q1.__str__()) r1 = Rectangle(0, 4, 6, 4, 6, 0, 0, 0) print(r1.__str__()) s1 = Square(0, 10, 10, 10, 10, 0, 0, 0) print(s1.__str__()) print(r1._Rectangle__is_member())
def test__str(self): q1 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0) self.assertEqual(q1.__str__(), "Quadrilateral: (0, 4) (6, 4) (6, 0) (0, 0) ")