def test_smallest_x(self): 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) self.assertEqual(q1.smallest_x(), 0) self.assertEqual(q2.smallest_x(), -5) self.assertEqual(q3.smallest_x(), 0)
def test_smallest_x(self): print("Testing smallest_x 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) self.assertEqual(A.smallest_x(), -3.5) self.assertNotEqual(B.smallest_x(), -1.0) print("Done testing smallest_x method successfully")
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)")
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_smallest_x(self): a = Quadrilateral(6, 1.5, 1, 1.5, 0, 0, 5, 0) b = Quadrilateral(5, 1, 1, 1, 1, 0, 5, 0) self.assertEqual(a.smallest_x(), 0) self.assertEqual(b.smallest_x(), 1)
def test_smallest_x(self): q1 = Quadrilateral(0, 4, 6, 4, 6, 0, 0, 0) self.assertTrue(q1.smallest_x() == 0)