Пример #1
0
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.obj = JudgeMethod()

    def test_case1(self):
        print("test the case of not a triangle")
        self.assertEqual(self.obj.TriJud(1, 2, 3), "not a triangle")
        self.assertEqual(self.obj.TriJud(2, 1, 3), "not a triangle")
        self.assertEqual(self.obj.TriJud(3, 2, 1), "not a triangle")
        self.assertEqual(self.obj.TriJud(3, 7, 3), "not a triangle")
        self.assertEqual(self.obj.TriJud(4, 7, 3), "not a triangle")

    def test_case2(self):
        print("test the case of scalene")
        self.assertEqual(self.obj.TriJud(2, 4, 3), "scalene")
        self.assertEqual(self.obj.TriJud(7, 5, 3), "scalene")
        self.assertEqual(self.obj.TriJud(3, 5, 6), "scalene")

    def test_case3(self):
        print("test the case of equilateral")
        self.assertEqual(self.obj.TriJud(2, 2, 2), "equilateral")
        self.assertEqual(self.obj.TriJud(3, 3, 3), "equilateral")
        self.assertEqual(self.obj.TriJud(5, 5, 5), "equilateral")

    def test_case4(self):
        print("test the case of isosceles")
        self.assertEqual(self.obj.TriJud(2, 2, 3), "isosceles")
        self.assertEqual(self.obj.TriJud(3, 4, 3), "isosceles")
        self.assertEqual(self.obj.TriJud(6, 5, 5), "isosceles")
class MyTestCase(unittest.TestCase):
    def setUp(self):
        self.obj = JudgeMethod()

    @given(a=st.integers(max_value=100, min_value=2),
           b=st.integers(max_value=100, min_value=2))
    def test_case1(self, a, b):
        c = a + b + 1
        print("test the case of not a triangle for ", a, b, c)
        self.assertEqual(self.obj.TriJud(a, b, c), "not a triangle")
        self.assertEqual(self.obj.TriJud(a, c, b), "not a triangle")
        self.assertEqual(self.obj.TriJud(c, a, b), "not a triangle")

    @given(a1=st.integers(max_value=100, min_value=2),
           b1=st.integers(max_value=100, min_value=2))
    def test_case2(self, a1, b1):
        if a1 == b1:
            return
        c = a1 + b1 - 1
        print("test the case of scalene for ", a1, b1, c)
        self.assertEqual(self.obj.TriJud(a1, b1, c), "scalene")
        self.assertEqual(self.obj.TriJud(a1, c, b1), "scalene")
        self.assertEqual(self.obj.TriJud(c, a1, b1), "scalene")

    @given(a2=st.integers(max_value=100, min_value=2))
    def test_case3(self, a2):

        print("test the case of equilateral for ", a2, a2, a2)
        self.assertEqual(self.obj.TriJud(a2, a2, a2), "equilateral")

    @given(a3=st.integers(max_value=100, min_value=2),
           b3=st.integers(max_value=100, min_value=2))
    def test_case4(self, a3, b3):

        if a3 == b3:
            return
        c = max(a3, b3)
        print("test the case of isosceles for ", a3, b3, c)
        self.assertEqual(self.obj.TriJud(a3, b3, c), "isosceles")
        self.assertEqual(self.obj.TriJud(a3, c, b3), "isosceles")
        self.assertEqual(self.obj.TriJud(c, a3, b3), "isosceles")
Пример #3
0
 def test_my_judge_1(self):
     print('execute test_one')
     obj = JudgeMethod()
     assert obj.TriJud(1, 2, 3) == "not a triangle"
Пример #4
0
 def test_my_judge_6(self):
     print('execute test_six')
     obj = JudgeMethod()
     assert obj.TriJud(2, 3, 4) == "scalene"
Пример #5
0
 def test_my_judge_5(self):
     print('execute test_five')
     obj = JudgeMethod()
     assert obj.TriJud(1, 1, 1) == "equilateral"
Пример #6
0
 def test_my_judge_4(self):
     print('execute test_four')
     obj = JudgeMethod()
     assert obj.TriJud(1, 2, 1) == "not a triangle"
Пример #7
0
 def test_my_judge_3(self):
     print('execute test_three')
     obj = JudgeMethod()
     assert obj.TriJud(2, 2, 3) == "isosceles"
Пример #8
0
 def test_my_judge_2(self):
     print('execute test_two')
     obj = JudgeMethod()
     assert obj.TriJud(1, 2, 2) == "isosceles"
Пример #9
0
 def setUp(self):
     self.obj = JudgeMethod()