# THIS CODE IS SUPPOSED TO: # Function count_pairs takes a list of integers. # Count the number of unique pairs of numbers that sum to 10 in the incoming list. # The incoming list is all unique integers. # A number may be used more than once to form a sum, # and each ordering of pairs is counted as a sum # -- so if the numbers 1 and 9 appear in the list, (1,9) and (9,1) are both pairs # and therefore generate two pairs that add in towards the total sum of pairs. # # Write test cases to find an unknown bug in the function. # # Do not look at the code. # You only need a specification to create test cases. # def count_pairs(lst): count = 0 for i in lst: for j in lst: if (i + j == 10) : count += 1 return count actualResults = [] expectedResults = [] #WRITE YOUR TESTS BELOW FOLLOWING THE FORMAT actualResults.append(count_pairs([])) expectedResults.append(0) actualResults.append(count_pairs([1])) expectedResults.append(0) actualResults.append(count_pairs([1,2])) expectedResults.append(0) actualResults.append(count_pairs([4,6])) expectedResults.append(2) #===================================# 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.")