# THIS CODE IS SUPPOSED TO: Gets two numbers from the user, and # returns the remainder of dividing the second number by the first. # Hint: the modulus operator, %, returns the remainder of a # division. For example, 7 % 3 returns 1, because 7 divided by 3 # yields 6, and the remainder when we subtract 6 from 7 is 1. # It has a bug; try to write test cases to reveal the bug # # Do not look at the code. # You only need a specification to create test cases. # def template(number1, number2): result = number1 % number2 return result actualResults = [] expectedResults = [] #WRITE YOUR TESTS BELOW FOLLOWING THE FORMAT actualResults.append(template(1,1)) expectedResults.append(0) #===================================# # ISP: input-based # 1. Identify inputs: n1, n2 # 2. Find characteristics of inputs: # - There are several ways: # -- define characteristics based on individual values # that is, the input can be 0, negavite, or positive # -- define characteristics based on the difference between the two inputs # that is, n1-n2 = 0, n1-n2 < 0, n1-n2 > 0 # Assume the characteristics are defined with the second way # therefore, we have only 1 characteristic. # C1: the difference between n1 and n2 # 3. Partition each characteristic and identify values # C1, P1: n1=n2, P2: n1n2 # possible value, P1: (n1=3, n2=3), P2: (n1=3, n2=7), P3: (n1=7, n2=3) # 4. Choose tests and specify expected results # T1 (3, 3), expected 0 # T2 (3, 7), expected 1 # T3 (7, 3), expected 3 ''' actualResults.append(template(3,7)) expectedResults.append(1) actualResults.append(template(7,3)) expectedResults.append(3) ''' #===================================# ctr = 0 found = False while ctr < len(actualResults): actual = actualResults[ctr] expected = expectedResults[ctr] print(str(expected) + " : " + str(actual)) if (actual != expected): found = True ctr = ctr + 1 if (found == True): print("Your test suite found the bug!!") else: print("Try writing more tests, you didn't find the bug yet.") ''' correct code result = number2 % number1 '''