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)
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")
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())
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())
def test_zero_numbers(self): triangle = Triangle((0, 0), (0, 0), (0, 0)) assert triangle.area_calculation( ) == 0, "area_calculation works wrong with zero numbers"
def test_mixed_numbers(self): triangle = Triangle((1.1, -5), (0, 0), (123456789, 123456789)) assert triangle.area_calculation( ) == 376543206.45, "area_calculation works wrong with mixed numbers"
def test_negative_numbers(self): triangle = Triangle((-5, -8), (-1, -4), (-6, -1)) assert triangle.area_calculation( ) == 16.0, "area_calculation works wrong with negative numbers"
def test_float_numbers(self): triangle = Triangle((5.5, 2.1), (8.4, 3.9), (6.5, 1.1)) assert triangle.area_calculation( ) == 2.3500000000000005, "area_calculation works wrong with float numbers"
def test_positive_numbers(self): triangle = Triangle((5, 3), (2, 4), (1, 8)) assert triangle.area_calculation( ) == 5.5, "area_calculation works wrong with positive numbers"