コード例 #1
0
 def test_sca(self):
     # Test scalene triangles
     self.assertEqual(classify_triangle(7, 8, 9), "Scalene Triangle")
     self.assertEqual(classify_triangle(3, 4, 5), "Right Scalene Triangle")
     self.assertEqual(classify_triangle(3.10101, 3.10102, 3.10103),
                      "Scalene Triangle")
     self.assertNotEqual(classify_triangle(3.10101, 3.10101, 3.10102),
                         "Scalene Triangle")
コード例 #2
0
 def test_iso(self):
     # Test isosceles triangles
     self.assertEqual(classify_triangle(5.1, 5.1, 3), "Isosceles Triangle")
     self.assertEqual(classify_triangle(1, 1, sqrt(2)),
                      "Right Isosceles Triangle")
     self.assertNotEqual(classify_triangle(5.1, 5.1, 12),
                         "Isosceles Triangle")  # Not even a triangle
     self.assertNotEqual(classify_triangle(5.1, 5.1, 5.1),
                         "Isosceles Triangle")
コード例 #3
0
    def test_clasify_triangle(self):
        #For Equilateral
        self.assertEqual(classify_triangle(3, 3, 3),
                         'It is an equilateral triangle')

        #For Isoceles
        self.assertEqual(classify_triangle(2, 2, 3),
                         "It is an isoceles triangle")

        #For scalene
        self.assertEqual(classify_triangle(1, 2, 3),
                         "It is a scalene triangle")

        #For right
        self.assertEqual(classify_triangle(3, 4, 5),
                         "It is a scalene right triangle")
コード例 #4
0
 def test_rig(self):
     # Test right triangles
     self.assertEqual(classify_triangle(3, 4, 5), "Right Scalene Triangle")
     self.assertEqual(classify_triangle(12, 5, 13),
                      "Right Scalene Triangle")
     self.assertEqual(classify_triangle(0.3, 0.5, 0.4),
                      "Right Scalene Triangle")
     self.assertEqual(classify_triangle(0.12, 0.05, 0.13),
                      "Right Scalene Triangle")
     self.assertNotEqual(classify_triangle(7, 8, 9),
                         "Right Scalene Triangle")
     self.assertEqual(classify_triangle(1, 1, sqrt(2)),
                      "Right Isosceles Triangle")
コード例 #5
0
ファイル: HW01_test.py プロジェクト: Connorsmith25/SSW567
 def test_classify_triangle(self):
     self.assertEqual(classify_triangle(3, 14, 5), "Not a Triangle!")
     self.assertEqual(classify_triangle(0, 11, 5), "Not a Triangle!")
     self.assertEqual(classify_triangle(7, 7, 7), "Equilateral Triangle")
     self.assertEqual(classify_triangle(16, 16, 16), "Equilateral Triangle")
     self.assertEqual(classify_triangle(9, 4, 9), "Isosceles Triangle")
     self.assertEqual(classify_triangle(9, 14, 14), "Isosceles Triangle")
     self.assertEqual(
         classify_triangle(10, 5 * math.sqrt(2), 5 * math.sqrt(2)),
         "Isosceles and Right Triangle")
     self.assertEqual(classify_triangle(3, 4, 5),
                      "Scalene and Right Triangle")
     self.assertEqual(classify_triangle(12, 5, 13),
                      "Scalene and Right Triangle")
     self.assertEqual(classify_triangle(9, 8, 7), "Scalene Triangle")
     self.assertEqual(classify_triangle(13, 7, 14), "Scalene Triangle")
コード例 #6
0
 def test_zne(self):
     # Test zero or negative length of edge (Not even a triangle)
     self.assertEqual(classify_triangle(0, 0, 0), None)
     self.assertEqual(classify_triangle(0, 1, 1), None)
     self.assertEqual(classify_triangle(-2, -2, -3), None)
コード例 #7
0
 def test_equ(self):
     # Test equilateral triangles
     self.assertEqual(classify_triangle(3, 3, 3), "Equilateral Triangle")
     self.assertEqual(classify_triangle(3.1, 3.1, 3.1),
                      "Equilateral Triangle")
     self.assertNotEqual(classify_triangle(4, 4, 2), "Equilateral Triangle")
コード例 #8
0
 def test_classify_triangle(self):
     """test if it's a triangle"""
     self.assertEqual(classify_triangle(1, 2, 3), "It's not a triangle.")
     self.assertEqual(classify_triangle(2, 1, 3), "It's not a triangle.")
     """test if it's a equilateral"""
     self.assertEqual(classify_triangle(5, 5, 5), "It's an equilateral triangle.")
     self.assertEqual(classify_triangle(2, 2, 2), "It's an equilateral triangle.")
     """test if it's a isosceles and right"""
     self.assertEqual(classify_triangle(1, 1, sqrt(2)), "It's an isosceles and right triangle.")
     self.assertEqual(classify_triangle(sqrt(2), 1, 1), "It's an isosceles and right triangle.")
     """test if it's a isosceles"""
     self.assertEqual(classify_triangle(3, 3, 5), "It's an isosceles triangle.")
     self.assertEqual(classify_triangle(4, 3, 3), "It's an isosceles triangle.")
     """test if it's a right and scalene"""
     self.assertEqual(classify_triangle(3, 4, 5), "It's a right and scalene triangle.")
     self.assertEqual(classify_triangle(4, 1, sqrt(17)), "It's a right and scalene triangle.")
     """test if it's a scalene"""
     self.assertEqual(classify_triangle(4, 5, 6), "It's a scalene triangle.")
     self.assertEqual(classify_triangle(7, 2, 6), "It's a scalene triangle.")
コード例 #9
0
ファイル: HW01_Testing.py プロジェクト: NAruneshwar/Testing
 def test_triangle(self):
     self.assertEqual(classify_triangle(8,8,8),"equilateral triangle")
     self.assertEqual(classify_triangle(0,0,0),"not a triangle")           #failed testcase the program doesnt handle it and returns equilateral triangle
     self.assertEqual(classify_triangle(8,5,25),"not a triangle")
     self.assertEqual(classify_triangle(3,4,5),"right triangle")
     self.assertEqual(classify_triangle(13,5,12),"right triangle")
     self.assertEqual(classify_triangle(8,8,7),"isosceles triangle")
     self.assertEqual(classify_triangle(8,8,1),"not a triangle")     #test case passes even though it qualifies isosceles properties as it has two same lengths it isnt a triangle
     self.assertEqual(classify_triangle(7,8,9),"scalene triangle")
     self.assertEqual(classify_triangle(10,11,12),"scalene triangle")
     self.assertEqual(classify_triangle(16,15,30),"scalene triangle")
     self.assertEqual(classify_triangle(-1,-4,1),"not a triangle")
コード例 #10
0
 def test_equilateral(self):
     self.assertEqual(classify_triangle(4, 4, 4), 'equilateral')
     self.assertEqual(classify_triangle(7, 7, 7), 'equilateral')
コード例 #11
0
 def test_scalene(self):
     self.assertEqual(classify_triangle(4, 5, 6), 'scalene')
     self.assertEqual(classify_triangle(7, 12, 10), 'scalene')
コード例 #12
0
 def test_invalid(self):
     self.assertEqual(classify_triangle(2, 4, 0), 'Invalid')
     self.assertEqual(classify_triangle(-2, -4, 0), 'Invalid')
コード例 #13
0
 def test_isosceles(self):
     self.assertEqual(classify_triangle(3, 4, 4), 'isosceles')
     self.assertEqual(classify_triangle(5, 7, 7), 'isosceles')
コード例 #14
0
 def test_right(self):
     self.assertEqual(classify_triangle(3, 4, 5), 'right')