# THIS CODE IS SUPPOSED TO: # Gets the radius of a circle from the user, # and returns the approximation of the circle's area. # If the radius entered is not valid (i.e., <= 0), # it returns the string "not a circle". # Use 3.14 as the value for pi. # # 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): radius = number1 if (radius > 0): result = 2*3.14*radius else: result = "not a circle" return result actualResults = [] expectedResults = [] #WRITE YOUR TESTS BELOW FOLLOWING THE FORMAT actualResults.append(template(0)) expectedResults.append("not a circle") #===================================# ''' actualResults.append(template(-2)) expectedResults.append("not a circle") actualResults.append(template(2)) expectedResults.append(12.56) actualResults.append(template(3)) # find bug expectedResults.append(28.26) ''' #===================================# 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 = 3.14*radius**2 '''