You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/test_sorting.py

50 lines
984 B

import random
import unittest
import sorting
class TestInsertionSort(unittest.TestCase):
def test_example(self):
tmpl = [8, 2, 4, 9, 3, 6]
a = tmpl[:]
expected = [2, 3, 4, 6, 8, 9]
sorting.insertion_sort(a)
self.assertEqual(expected, a)
13 years ago
def test_100_example(self):
tmpl = list(range(0, 1000))
a = tmpl[:]
random.shuffle(a)
expected = tmpl[:]
sorting.insertion_sort(a)
self.assertEqual(expected, a)
13 years ago
def test_reversed_100_example(self):
tmpl = list(range(0, 1000))
a = list(reversed(tmpl[:]))
expected = tmpl[:]
sorting.insertion_sort(a)
13 years ago
self.assertEqual(expected, a)
def test_1000_example(self):
tmpl = list(range(0, 1000))
a = tmpl[:]
random.shuffle(a)
expected = tmpl[:]
sorting.insertion_sort(a)
self.assertEqual(expected, a)
if __name__ == '__main__':
unittest.main()