41 lines
795 B
Python
41 lines
795 B
Python
import random
|
|
import unittest
|
|
|
|
import insertion_sort01
|
|
|
|
|
|
class Test(unittest.TestCase):
|
|
|
|
def test_example(self):
|
|
tmpl = [8, 2, 4, 9, 3, 6]
|
|
a = tmpl[:]
|
|
expected = [2, 3, 4, 6, 8, 9]
|
|
|
|
insertion_sort01.insertion_sort(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__':
|
|
unittest.main()
|