Exemple #1
0
 def testEquilateralTriangles(self):
     self.assertEqual(classify_triangle(1, 1, 1), 'Equilateral',
                      '1,1,1 should be equilateral')
     self.assertEqual(classify_triangle(3, 3, 3), 'Equilateral',
                      '1,1,1 should be equilateral')
     self.assertEqual(classify_triangle(7, 7, 7), 'Equilateral',
                      '1,1,1 should be equilateral')
 def testScalene(self):
     self.assertEqual(classify_triangle(3, 5, 6), 'Scalene')
     """ all of the sides are not equal with one input sequence"""
     self.assertEqual(classify_triangle(5, 3, 6), 'Scalene')
     """ all of the sides are not equal with another input sequence"""
     self.assertEqual(classify_triangle(3, 4, 5), 'RightScalene')
     """ all of the sides are not equal but satisfy with the requirement of right angle"""
Exemple #3
0
 def testScaleneTriangleA(self):
     """ Test for Scalene Triangles """
     self.assertEqual(classify_triangle(4, 5, 6), 'Scalene', '4,5,6 is a Scalene Triangle')
     self.assertNotEqual(classify_triangle(3, 3, 5), 'Scalene', '3,3,5 is not a scalene triangle')
     self.assertNotEqual(classify_triangle(3, 5, 3), 'Scalene', '3,5,3 is not a scalene triangle')
     self.assertNotEqual(classify_triangle(5, 3, 3), 'Scalene', '3,4,5 is not a scalene triangle')
     self.assertNotEqual(classify_triangle(3, 4, 5), 'Scalene', '3,4,5 is not a scalene triangle')
Exemple #4
0
 def testIsoscelesTriangleA(self):
     """ Test for Isoceles Triangles """
     self.assertEqual(classify_triangle(4, 8, 4), 'Isosceles', '4,8,4 is an Isosceles Triangle')
     self.assertEqual(classify_triangle(4, 4, 8), 'Isosceles', '4,4,8 is an Isosceles Triangle')
     self.assertEqual(classify_triangle(8, 4, 4), 'Isosceles', '8,4,4 is an Isosceles Triangle')
     self.assertNotEqual(classify_triangle(3, 6, 5), 'Isosceles', '3,6,5 is not an Isosceles Triangle')
     self.assertNotEqual(classify_triangle(3, 3, 3), 'Isosceles', '3,3,3 is not an Isosceles Triangle')        
Exemple #5
0
    def testInvalidInput(self):
        """
        T1
        2. Verify the Input
        """
        self.assertEqual(classify_triangle(2, 2, -3), 'not valid')

        self.assertEqual(classify_triangle('a', '2', 3), 'not valid')
 def test_right_triangle_c(self):
     """ nnn """
     self.assertEqual(classify_triangle(1, 2, 3), "NotATriangle",
                      '1,2,3 is NotATriangle')
     self.assertEqual(classify_triangle(1, 1, 5), "NotATriangle",
                      '1,1,5 is NotATriangle')
     self.assertEqual(classify_triangle(10, 1, 5), "NotATriangle",
                      '10,1,5 is NotATriangle')
Exemple #7
0
 def testNotATriangle(self):
     self.assertEqual(classify_triangle(0, 0, 0), 'NotATriangle',
                      'side lengths of zero')
     self.assertEqual(classify_triangle(25, 10, 11), 'NotATriangle',
                      '25,10,11 is not a triangle because 10+11 < 25')
     self.assertEqual(
         classify_triangle(34, 34, -35), 'NotATriangle',
         '34.5, 34.5, -35 is not a triangle because it has a negative side length'
     )
Exemple #8
0
    def testRightTriangle(self):
        """
        T3
        4. Determine if the triangle is a right triangle
        6. Display type of triangle
        """
        self.assertEqual(classify_triangle(1, 1, 1.414213),
                         'isosceles and right')

        self.assertEqual(classify_triangle(3, 4, 5), 'scalene and right')
 def testInvalidInputs(self):
     self.assertEqual(
         classify_triangle(300, 300, 300), 'InvalidInput',
         '300, 300, 300 is invalid input and not "Equilateral"')
     self.assertEqual(classify_triangle(-3, -4, -5), 'InvalidInput',
                      '-3, -4, -5 is invalid input and not "Right"')
     self.assertEqual(classify_triangle("2", 2, 2), 'InvalidInput',
                      '"2" is a string and invalid input')
     self.assertEqual(classify_triangle(1, 2, 3), 'NotATriangle',
                      '1, 2, 3 is not a triangle')
Exemple #10
0
 def testScaleneTriangle(self):
     """
     T6
     5.2 Else if two side are equal, but not three, then the triangle is “Isosceles”
     6. Display type of triangle
     """
     self.assertEqual(classify_triangle(4, 5, 6), 'scalene')
Exemple #11
0
 def testIsoscelesTriangle(self):
     """
     T5
     5.2 Else if two side are equal, but not three, then the triangle is “Isosceles”
     6. Display type of triangle
     """
     self.assertEqual(classify_triangle(2, 2, 3), 'isosceles')
Exemple #12
0
 def testEquilateralTriangle(self):
     """
     T4
     5.1 If the sides are all equal, then the triangle is “Equilateral”
     6. Display type of triangle
     """
     self.assertEqual(classify_triangle(1, 1, 1), 'equilateral')
Exemple #13
0
 def testInvalidTriangle(self):
     """
     T2
     3. Verify that the sides form a legal triangle
     :return:
     """
     self.assertEqual(classify_triangle(1, 2, 3), 'not valid')
 def testLargeAndSmallInputs(self):
     self.assertEqual(classify_triangle(201, 4, 5), 'InvalidInput')
     self.assertEqual(classify_triangle(4, 201, 5), 'InvalidInput')
     self.assertEqual(classify_triangle(4, 5, 201), 'InvalidInput')
     self.assertEqual(classify_triangle(-1, 5, 8), 'InvalidInput')
     self.assertEqual(classify_triangle(5, -1, 8), 'InvalidInput')
     self.assertEqual(classify_triangle(5, 4, -1), 'InvalidInput')
Exemple #15
0
 def testTriangleClassification(self):
     self.assertEqual(classify_triangle(3, 4, 5), 'Scalene Triangle')
     self.assertEqual(classify_triangle(4, 4, 5), 'Scalene Triangle',
                      'should fail')
     self.assertEqual(classify_triangle(3, 4, 7), 'Isosceles Triangle',
                      'should fail')
     self.assertEqual(classify_triangle(3, 3, 5), 'Isosceles Triangle')
     self.assertEqual(classify_triangle(3, 8, 3), 'Equilateral Triangle',
                      'should fail')
     self.assertEqual(classify_triangle(7, 7, 7), 'Equilateral Triangle')
 def test_right_triangle_b(self):
     """" m """
     self.assertNotEqual(classify_triangle(222, 222, 222),
                         'Equilateral Triangle', '222,222,222 is invalid')
     self.assertEqual(classify_triangle('A', 'B', 'C'), 'InvalidInput',
                      'A,B,C is invalid input')
     self.assertEqual(classify_triangle(-4, 3, 9), 'InvalidInput',
                      '-4,3,9 is invalid input')
     self.assertEqual(classify_triangle(2, '/', 'M'), 'InvalidInput',
                      '2,/,M is invalid input')
     self.assertEqual(classify_triangle(0, 10, 101), 'InvalidInput',
                      '0,10,101 is invalid input')
     self.assertEqual(classify_triangle(33, 110, 469), 'InvalidInput',
                      '33,110,469 is invalid input')
     self.assertEqual(classify_triangle(2, 0, 2), "InvalidInput",
                      '2,0,2 is invalid input')
 def test013(self):
     self.assertEqual(classify_triangle(3, 1, 2), 'NotATriangle')
 def test025(self):
     self.assertEqual(classify_triangle(1, 1, 2 ** 0.5), 'Right Isosceles')
 def test_right_triangle_a(self):
     """ m """
     self.assertEqual(classify_triangle(3, 4, 5), 'Right Scalene Triangle',
                      '3,4,5 is a Right triangle')
     self.assertEqual(classify_triangle(2, 2, 2), "Equilateral Triangle",
                      '2,2,2 is a Equilateral triangle')
     self.assertEqual(classify_triangle(4, 4, 4), "Equilateral Triangle",
                      '4,4,4 is a Equilateral triangle')
     self.assertEqual(classify_triangle(4, 3, 4), "Isosceles Triangle",
                      '4,3,4 is not a Isosceles triangle')
     self.assertEqual(classify_triangle(2, 3, 4), "Scalene Triangle",
                      '2,3,4 is a Scalene triangle')
     self.assertEqual(classify_triangle(3, 4, 6), "Scalene Triangle",
                      '3,4,6 is a Scalene triangle')
     self.assertEqual(classify_triangle(5, 3, 4), 'Right Scalene Triangle',
                      '5,3,4 is a Right triangle')
     self.assertEqual(classify_triangle(1, 1, 1), 'Equilateral Triangle',
                      '1,1,1 should be equilateral')
     self.assertEqual(classify_triangle(7, 24,
                                        25), 'Right Scalene Triangle',
                      '7,24,25 is a Right triangle')
     self.assertEqual(classify_triangle(5, 12, 13),
                      'Right Scalene Triangle', '5,3,4 is a Right triangle')
     self.assertEqual(classify_triangle(7, 7, 4), "Isosceles Triangle",
                      '4,3,4 is an Isosceles triangle')
     self.assertEqual(classify_triangle(2, 2,
                                        2.8), "Right Isosceles Triangle",
                      '2,2,2.8 is an Right Isosceles Triangle')
 def test023(self):
     self.assertEqual(classify_triangle(3, 4, 2), 'Scalene')
 def test024(self):
     self.assertEqual(classify_triangle(4, 2, 3), 'Scalene')
 def test021(self):
     self.assertEqual(classify_triangle(2, 2, 1), 'Isosceles')
 def test022(self):
     self.assertEqual(classify_triangle(2, 3, 4), 'Scalene')
 def test018(self):
     self.assertEqual(classify_triangle(1, 1, 1), 'Equilateral')
 def test019(self):
     self.assertEqual(classify_triangle(1, 2, 2), 'Isosceles')
 def test017(self):
     self.assertNotEqual(classify_triangle(2, 3, 4), 'Right Scalene')
 def test016(self):
     self.assertEqual(classify_triangle(5, 3, 4), 'Right Scalene')
 def test015(self):
     self.assertEqual(classify_triangle(4, 5, 3), 'Right Scalene')
 def test014(self):
     self.assertEqual(classify_triangle(3, 4, 5), 'Right Scalene')
 def test012(self):
     self.assertEqual(classify_triangle(2, 3, 1), 'NotATriangle')