Example #1
0
 def test_add1(self):
     print("测试两个整数函数")
     a1 = Count(10, 20)
     res1 = a1.add()
     print("计算实际结果:", res1)
     #步骤5:使用unittest提供的断言函数
     self.assertEqual(res1, 30)
Example #2
0
 def test_add(self):
     print("测试add函数")
     c1 = Count(10, 20)
     res1 = c1.add()
     print("计算实际结果:", res1)
     #步骤5:使用unittest提供的断言函数
     self.assertEqual(res1, 30)
Example #3
0
 def test_add(self):
     c1 = Count(10, 20)
     res1 = c1.add()
     if res1 == 30:
         print("计算正确!")
     else:
         print("计算错误!")
     print("计算实际结果:", res1)
Example #4
0
 def test_sub2(self):
     print("测试浮点数sub")
     s2 = Count(4589.87, 3978.78)
     res2 = s2.sub()
     print("实际计算结果:", res2)
     if abs(res2 - 611.09) < 0.01:
         res2 = 611.09
     self.assertEqual(res2, 611.09)
Example #5
0
 def test_div2(self):
     print("测试两个浮点型数据div")
     d2 = Count(245.45, 34.67)
     res2 = d2.div()
     print("实际计算结果:", res2)
     if abs(res2 - 7.0796) < 0.01:
         res2 = 7.0796
     self.assertEqual(res2, 7.0796)
Example #6
0
 def test_mul2(self):
     print("测试两个浮点型数据mul")
     m2 = Count(20.45, 45.67)
     res2 = m2.mul()
     print("实际计算结果:", res2)
     if abs(res2 - 933.9515) < 0.01:
         res2 = 933.9515
     self.assertEqual(res2, 933.9515)
Example #7
0
 def test_add2(self):
     print("测试两个浮点型数据函数")
     c2=Count(2167.45,3978.78)
     res2=c2.add()
     print("计算实际结果:",res2)
     if abs(res2-6146.23)<0.001:
         res2=6146.23
     self.assertEqual(res2,6146.23)
Example #8
0
 def test_add(self):
     c1 = Count("你好", "Python!")
     res1 = c1.add()
     if res1 == "你好Python!":
         print("计算正确!")
     else:
         print("计算错误!")
     print("计算实际结果:", res1)
Example #9
0
 def test_mul1(self):
     print("使用多组数据测试两个整数mul")
     i = 0
     for x, y in zip(list1_zhengshu, list2_zhengshu):
         m1 = Count(x, y)
         res_zhengshu[i] = m1.mul()
         print("计算实际结果:", res_zhengshu[i])
         i = i + 1
     for res, res_right in zip(res_zhengshu, res_zhengshuRight):
         self.assertEqual(res, res_right)
Example #10
0
 def test_add1(self):
     print("使用多组数据测试两个整数函数")
     i = 0
     for x, y in zip(list1_zhengshu, list2_zhengshu):
         a1 = Count(x, y)
         res_zhengshu[i] = a1.add()
         print("计算实际结果:", res_zhengshu[i])
         i = i + 1
     for res, res_right in zip(res_zhengshu, res_zhengshuRight):
         self.assertEqual(res, res_right)
Example #11
0
 def test_add3(self):
     print("使用多组数据测试两个字符串函数")
     i = 0
     for x, y in zip(list1_zifuchaun, list2_zifuchaun):
         a3 = Count(x, y)
         res_zifuchaun[i] = a3.add()
         print("计算实际结果:", res_zifuchaun[i])
         i = i + 1
     for res, res_right in zip(res_zifuchaun, res_zifuchaunRight):
         self.assertEqual(res, res_right)
Example #12
0
 def test_sub1(self):
     print("使用多组数据测试两个整数函数sub")
     i = 0
     for x, y in zip(list1_zhengshu, list2_zhengshu):
         s1 = Count(y, x)
         res_zhengshu[i] = s1.sub()
         print("计算实际结果:", res_zhengshu[i])
         i = i + 1
     for res, res_right in zip(res_zhengshu, res_zhengshuRight):
         self.assertEqual(res, res_right)
Example #13
0
 def test_div1(self):
     print("使用多组数据测试两个整数div")
     i = 0
     for x, y in zip(list1_zhengshu, list2_zhengshu):
         d1 = Count(y,x)
         res_zhengshu[i] = d1.div()
         print("计算实际结果:", res_zhengshu[i])
         i = i + 1
     for res, res_right in zip(res_zhengshu, res_zhengshuRight):
         self.assertEqual(res, res_right)
Example #14
0
 def test_div2(self):
     print("使用多组数据测试两个浮点型数据div")
     i = 0
     for x, y in zip(list1_fudianshu, list2_fudianshu):
         d2 = Count(y, x)
         res_fudianshu[i] = d2.div()
         print("计算实际结果:", res_fudianshu[i])
         i = i + 1
     for res, res_right in zip(res_fudianshu, res_fudianshuRight):
         if abs(res - res_right) < 0.001:
             res = res_right
         self.assertEqual(res, res_right)
Example #15
0
 def test_mul2(self):
     print("使用多组数据测试两个浮点型数据mul")
     i = 0
     for x, y in zip(list1_fudianshu, list2_fudianshu):
         m2 = Count(x, y)
         res_fudianshu[i] = m2.mul()
         print("计算实际结果:", res_fudianshu[i])
         i = i + 1
     for res, res_right in zip(res_fudianshu, res_fudianshuRight):
         if abs(res - res_right) < 0.001:
             res = res_right
         self.assertEqual(res, res_right)
Example #16
0
    def test_sub1(self):
        print("开始获取测试数据:")
        getdata = GetTestData()
        file = getdata.openDataFile("E:/Python/demo/csv/importData/zhengshuData.csv")
        zhengshuData = getdata.getData(file)

        i = 0
        for x, y in zip(zhengshuData[1], zhengshuData[0]):
            s1 = Count(int(x), int(y))
            zhengshuData[2][i] = str(s1.sub())
            print("计算实际结果:", zhengshuData[2][i])
            i = i + 1

        for res, res_right in zip(zhengshuData[2], zhengshuData[4]):
            self.assertEqual(res, res_right)
Example #17
0
    def test_add3(self):
        print("使用多组数据测试两个字符串函数add3")
        print("开始获取测试数据:")
        getdata = GetTestData()
        file = getdata.openDataFile(
            'E:/Python/demo/csv/importData/zifuchuanData.csv')
        zifuchuanData = getdata.getData(file)

        i = 0
        for x, y in zip(zifuchuanData[0], zifuchuanData[1]):
            a3 = Count(x, y)
            zifuchuanData[3][i] = a3.add()
            print("计算实际结果:", zifuchuanData[3][i])
            i = i + 1

        for res, res_right in zip(zifuchuanData[3], zifuchuanData[2]):
            self.assertEqual(res, res_right)
Example #18
0
    def test_mul1(self):
        print("使用多组数据测试两个整数mul")
        print("开始获取测试数据:")
        getdata = GetTestData()
        file = getdata.openDataFile(
            "E:/Python/demo/csv/importData/zhengshuData.csv")
        zhengshuData = getdata.getData(file)

        i = 0
        for x, y in zip(zhengshuData[1], zhengshuData[0]):
            m1 = Count(int(x), int(y))
            zhengshuData[2][i] = m1.mul()
            print("计算实际结果:", zhengshuData[2][i])
            i = i + 1

        i = 0
        for item in zhengshuData[5]:
            zhengshuData[5][i] = float(item)
            i = i + 1

        for res, res_right in zip(zhengshuData[2], zhengshuData[5]):
            self.assertEqual(res, res_right)
Example #19
0
    def test_sub2(self):
        print("使用多组数据测试两个浮点型数据函数sub")
        print("开始获取测试数据:")
        getdata = GetTestData()
        file = getdata.openDataFile('E:/Python/demo/csv/importData/fudianshuData.csv')
        fudianshuData = getdata.getData(file)

        i = 0
        for x, y in zip(fudianshuData[1], fudianshuData[0]):
            s2 = Count(float(x), float(y))
            fudianshuData[2][i] = s2.sub()
            print("计算实际结果:", fudianshuData[2][i])
            i = i + 1

        i = 0
        for item in fudianshuData[4]:
            fudianshuData[4][i] = float(item)
            i = i + 1

        for res, res_right in zip(fudianshuData[2], fudianshuData[4]):
            if abs(res - res_right) < 0.001:
                res = res_right
            self.assertEqual(res, res_right)
Example #20
0
 def test_add1(self):
     print("测试两个整数函数")
     c1=Count(10,20)
     res1=c1.add()
     print("计算实际结果:",res1)
     self.assertEqual(res1,30)
Example #21
0
 def test_add3(self):
     print("测试两个字符串函数")
     c3=Count("你好","测试")
     res3=c3.add()
     print("实际计算结果:",res3)
     self.assertEqual(res3,"你好测试")
Example #22
0
 def test_sub1(self):
     print("测试整数sub")
     s1 = Count(100, 20)
     res1 = s1.sub()
     print("实际计算结果:", res1)
     self.assertEqual(res1, 80)
Example #23
0
 def test_div1(self):
     print("测试两个整数div")
     d1 = Count(100, 20)
     res1 = d1.div()
     print("实际计算结果:", res1)
     self.assertEqual(res1, 5)
Example #24
0
#使用普通方法对Count类进行测试
#此文件只对add函数进行整数加测试

from calculator.calculatorPackage.mycalculator import Count

mytest = Count(10.56, 23.43)
res2 = mytest.add()
if abs(res2 - 33.99) <= 0.001:
    print("计算正确!")
else:
    print("计算错误!")
print("计算实际结果:", res2)
Example #25
0
 def test_mul1(self):
     print("测试两个整数mul")
     m1 = Count(10, 20)
     res1 = m1.mul()
     print("实际计算结果:", res1)
     self.assertEqual(res1, 200)