adding some more tests for insertion sort to compare performance given inputs of varying sizes
This commit is contained in:
parent
f0e703c695
commit
59465b1152
@ -1,3 +1,4 @@
|
|||||||
|
import random
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import insertion_sort01
|
import insertion_sort01
|
||||||
@ -14,6 +15,26 @@ class Test(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected, a)
|
self.assertEqual(expected, a)
|
||||||
|
|
||||||
|
def test_big_example(self):
|
||||||
|
tmpl = list(range(0, 1000))
|
||||||
|
a = tmpl[:]
|
||||||
|
random.shuffle(a)
|
||||||
|
expected = tmpl[:]
|
||||||
|
|
||||||
|
insertion_sort01.insertion_sort(a)
|
||||||
|
|
||||||
|
self.assertEqual(expected, a)
|
||||||
|
|
||||||
|
def test_bigger_example(self):
|
||||||
|
tmpl = list(range(0, 10000))
|
||||||
|
a = tmpl[:]
|
||||||
|
random.shuffle(a)
|
||||||
|
expected = tmpl[:]
|
||||||
|
|
||||||
|
insertion_sort01.insertion_sort(a)
|
||||||
|
|
||||||
|
self.assertEqual(expected, a)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user