pythonプログラム小テスト

6084 ワード

pythonプログラム小テスト
前に書いたプログラムに簡単なテストをします...
 1 # -*- encoding:utf-8 -*-
 2 '''
 3            
 4 @author: bpf
 5 '''
 6 def GameOver(N, scoreA, scoreB):
 7     '''
 8     function:              
 9     N:       (       )
10            ,          25 ,       2      
11            ,          15 ,       2      
12     return:              ,     15
13     '''
14     if N <= 4:
15         return (scoreA>=25 and abs(scoreA-scoreB)>=2) or (scoreB>=25 and abs(scoreA-scoreB)>=2)
16     else:
17         return (scoreA>=15 and abs(scoreA-scoreB)>=2) or (scoreB>=15 and abs(scoreA-scoreB)>=2)
18 
19 def Test():
20     try:
21         N = [1, 2, 3, 4, 5, 5, 5]
22         scoreA = [13, 24, 26, 24, 14, 17, 15]
23         scoreB = [25, 25, 25, 0, 16, 16, 0]
24         result = ["True", "False", "False", "False", "True", "False", "True"]
25         for i in range(0, 7):
26             if str(GameOver(N[i], scoreA[i], scoreB[i])) == result[i]:
27                 print("Test {}: Right Result!".format(i+1))
28             else:
29                 print("Test {}: Error Result!".format(i+1))
30     except Exception as e:
31         print("Error:", e) 2 
33 Test()

 
参考文献:
① https://www.liaoxuefeng.com/wiki/897692888725344/923056208268256
② https://blog.csdn.net/u012084802/article/details/79481254
③ https://www.cnblogs.com/springionic/p/10711796.html
④ https://docs.python.org/2/library/profile.html
⑤ https://blog.csdn.net/asukasmallriver/article/details/74356771