From 59465b11529cd0a31fb61174676a0e7ef7e54020 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 15 Aug 2011 06:57:09 -0400 Subject: [PATCH] adding some more tests for insertion sort to compare performance given inputs of varying sizes --- test_insertion_sort01.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test_insertion_sort01.py b/test_insertion_sort01.py index 47291ee..baff970 100644 --- a/test_insertion_sort01.py +++ b/test_insertion_sort01.py @@ -1,3 +1,4 @@ +import random import unittest import insertion_sort01 @@ -14,6 +15,26 @@ class Test(unittest.TestCase): 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()