I get the following response when running my tests.
When the error doen't pop up, I get an everything passed response.
check time: 27 2.40802764893e-05
bubble time: 25 0.000274181365967
check time: 25 2.19345092773e-05
bubblem time: 87 0.00342512130737
check time: 87 5.10215759277e-05
insertion time: 59 0.000833988189697
check time: 59 3.79085540771e-05
lame time: 33 0.00018310546875
check time: 33 2.71797180176e-05
All tests have passed
Press ENTER or type command to continue
# test:none -> none:
# here be tests:
def test():
import numpy, time
isPassing = True
for i in range (100):
sortMe = list(numpy.random.randint(numpy.random.randint(1000), size=numpy.random.randint(108)))
jackHarkness = time.time()
bubble(sortMe)
print "bubble time: ", len(sortMe), time.time() - jackHarkness
jackHarkness = time.time()
passed = isSorted(sortMe)
print "check time: ", len(sortMe), time.time() - jackHarkness
isPassing *= passed
if not passed: print "bubble failed"
sortMe = list(numpy.random.randint(numpy.random.randint(1000), size=numpy.random.randint(108)))
jackHarkness = time.time()
bubblem(sortMe)
print "bubblem time: ", len(sortMe), time.time() - jackHarkness
jackHarkness = time.time()
passed = isSorted(sortMe)
print "check time: ", len(sortMe), time.time() - jackHarkness
isPassing *= passed
if not passed: print "bubblem failed"
sortMe = list(numpy.random.randint(numpy.random.randint(1000), size=numpy.random.randint(108)))
jackHarkness = time.time()
insertion(sortMe)
print "insertion time: ", len(sortMe), time.time() - jackHarkness
jackHarkness = time.time()
passed = isSorted(sortMe)
print "check time: ", len(sortMe), time.time() - jackHarkness
isPassing *= passed
if not passed: print "insertion failed"
sortMe = list(numpy.random.randint(numpy.random.randint(1000), size=numpy.random.randint(108)))
jackHarkness = time.time()
lame(sortMe)
print "lame time: ", len(sortMe), time.time() - jackHarkness
jackHarkness = time.time()
passed = isSorted(sortMe)
print "check time: ", len(sortMe), time.time() - jackHarkness
isPassing *= passed
if not passed: print "lame failed"
sortMe = list(numpy.random.randint(numpy.random.randint(1000), size=numpy.random.randint(108)))
sortMeTwo, sortMeThree = list(sortMe), list(sortMe)
bubble(sortMe), bubblem(sortMeTwo), insertion(sortMeThree)
passed = sortMe == sortMeTwo and sortMeThree == sortMeTwo
isPassing *= passed
if not passed: print "comparison failed"
if isPassing:
print "All tests have passed"
if __name__ == "__main__": test()