def test_side_lengths(self):
     print("Testing side_lengths 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)
     aSide = (3.5, 7.8, 3.5, 7.8)
     bSide = (3.16228, 1.0, 3.16228, 3.0)
     self.assertEqual(aSide, A.side_lengths())
     self.assertEqual(bSide, B.side_lengths())
     self.assertNotEqual(aSide, (0, 0, 0, 0))
     print("Done testing side_lengths method successfully")
Beispiel #2
0
    def test_side_lengths(self):
        # coordinates = [2, 1, 0, 1, 0, 0, 2, 0]
        # coordinates2 = [-3, -2, -5, -2, -5, -3, -3, -3]
        # coordinates3 = [1, 1, 0, 1, 0, 0, 1, 0]
        q1 = Quadrilateral(2, 1, 0, 1, 0, 0, 2, 0)
        q2 = Quadrilateral(2, 4, -2, 4, -5, 0, 5, 0)  # Trapezoid
        q3 = Quadrilateral(1, 1, 0, 1, 0, 0, 1, 0)  # Square
        with self.assertRaises(TypeError) as error:
            q4 = Quadrilateral(1, 1, 0, 1, 0, 0, 1, 0, 5, 6) # Too many arguments

        self.assertEqual(q1.side_lengths(), (2, 1, 2, 1))
        self.assertNotEqual(q2.side_lengths(), (4, 5, 10, 5))
        self.assertEqual(q3.side_lengths(), (1, 1, 1, 1))
Beispiel #3
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)")
Beispiel #4
0
class TestQuadrilateral(unittest.TestCase):

    def setUp(self) -> None:
        self.q1 = Quadrilateral(1, 3, 0, 2, -1, 0, 0, 0)
        self.q2 = Quadrilateral(1, 1, 0, 1, 0, 0, 0, 1)

    def test_side_lengths(self):
        # (round(math.sqrt(2), 5), round(math.sqrt(10), 5), round(math.sqrt(1), 5), round(math.sqrt(5), 5))
        self.assertEqual(self.q1.side_lengths(), (math.sqrt(2), math.sqrt(10), math.sqrt(1), math.sqrt(5)))
        self.assertEqual(self.q2.side_lengths(), (1, 1, 1, 1))

    def test_smallest_x(self):
        self.assertEqual(self.q1.smallest_x(), -1)
        self.assertEqual(self.q2.smallest_x(), 0)

    def test___eq__(self):
        self.assertEqual(self.q1 == self.q1, True)
        self.assertEqual(self.q2 == self.q1, False)
 def test_side_lengths(self):
     a = Quadrilateral(6, 1.5, 1, 1.5, 0, 0, 5, 0)
     v = list(a.vertices)
     l = list(a.side_lengths())
     self.assertEqual((v[0].x - v[1].x), l[0].x)
     self.assertEqual((v[0].y - v[1].y), l[0].y)
     self.assertEqual((v[0].x - v[3].x), l[1].x)
     self.assertEqual((v[0].y - v[3].y), l[1].y)
     self.assertEqual((v[3].x - v[2].x), l[2].x)
     self.assertEqual((v[3].y - v[2].y), l[2].y)
     self.assertEqual((v[1].x - v[2].x), l[3].x)
     self.assertEqual((v[1].y - v[2].y), l[3].y)
Beispiel #6
0
 def test_side_lengths(self):
     q1 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0)
     self.assertTrue(q1.side_lengths() == (6, 4, 6, 4))