예제 #1
0
 def test_of_right_triangle_area(self):
     test_triangle = Functionality.Triangle(Functionality.Point(0, 0),
                                            Functionality.Point(0, 1),
                                            Functionality.Point(1, 0))
     self.assertEqual(Decimal('0.5'), test_triangle.area())
예제 #2
0
    def test_of_triangle_perimeter_on_sharp_triangle(self):
        test_triangle = Functionality.Triangle(Functionality.Point(1, 2),
                                               Functionality.Point(2, 5),
                                               Functionality.Point(5, 2))

        self.assertEqual(Decimal('11.40491834728766429307711405'), test_triangle.perimeter())
예제 #3
0
    def test_of_triangle_perimeter_on_obtuse_triangle(self):
        test_triangle = Functionality.Triangle(Functionality.Point(1, 3),
                                               Functionality.Point(3, 5),
                                               Functionality.Point(9, 3))

        self.assertEqual(Decimal('17.15298244508294933652337022'), test_triangle.perimeter())
예제 #4
0
 def test_of_triangle_contanting_to_point3(self):
     self.assertEqual(Functionality.Point(3, 3), Functionality.Triangle(Functionality.Point(1, 1),
                                                                        Functionality.Point(0, 2),
                                                                        Functionality.Point(3, 3)).point3)
예제 #5
0
    def test_of_triangle_perimeter_on_right_triangle(self):
        test_triangle = Functionality.Triangle(Functionality.Point(0, 0),
                                               Functionality.Point(0, 1),
                                               Functionality.Point(1, 0))

        self.assertEqual(Decimal('3.414213562373095145474621859'), test_triangle.perimeter())
예제 #6
0
 def test_of_triangle_with_equal_points(self):
     with self.assertRaises(Functionality.TriangleError) as raised_exception:
         Functionality.Triangle(Functionality.Point(1, 1), Functionality.Point(1, 1), Functionality.Point(2, 2))
     self.assertEqual(raised_exception.exception.args[0], 'Points should be different. Try again!')
예제 #7
0
 def test_of_triangle_with_points_on_one_line(self):
     with self.assertRaises(Functionality.TriangleError) as raised_exception:
         Functionality.Triangle(Functionality.Point(0, 0), Functionality.Point(1, 1), Functionality.Point(2, 2))
     self.assertEqual(raised_exception.exception.args[0], 'Points should not be located on the one line. Try again!')
예제 #8
0
 def test_of_triangle_with_wrong_type_of_argument(self):
     with self.assertRaises(Functionality.TriangleError) as raised_exception:
         Functionality.Triangle(2, Functionality.Point(1, 1), Functionality.Point(2, 1))
     self.assertEqual(raised_exception.exception.args[0], 'Point should be instance of class Point')
예제 #9
0
 def test_of_triangle_area_of_obtuse_triangle(self):
     test_triangle = Functionality.Triangle(Functionality.Point(1, 3),
                                            Functionality.Point(3, 5),
                                            Functionality.Point(9, 3))
     self.assertEqual(Decimal('8.0000000000000017763568394002504646778106689453125'), test_triangle.area())
예제 #10
0
    def test_of_triangle_area_of_sharp_triangle(self):
        test_triangle = Functionality.Triangle(Functionality.Point(1, 2),
                                               Functionality.Point(2, 5),
                                               Functionality.Point(5, 2))

        self.assertEqual(Decimal('6'), test_triangle.area())