From 602995c859265493dd94996d1626e6de44d512e6 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Sun, 17 Feb 2019 09:35:46 -0600 Subject: Build heap done! Not too bad, since the Java version has been worked out. --- tests/build_heapTest.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/build_heapTest.py (limited to 'tests') diff --git a/tests/build_heapTest.py b/tests/build_heapTest.py new file mode 100644 index 0000000..3b934bf --- /dev/null +++ b/tests/build_heapTest.py @@ -0,0 +1,25 @@ +import unittest + +from sources.build_heap import get_swaps + + +class MyTestCase(unittest.TestCase): + def test(self): + data = [5, 4, 3, 2, 1] + swaps = get_swaps(data) + self.assertEqual(len(swaps), 3) + self.assertEqual(1, swaps[0][0]) + self.assertEqual(4, swaps[0][1]) + self.assertEqual(0, swaps[1][0]) + self.assertEqual(1, swaps[1][1]) + self.assertEqual(1, swaps[2][0]) + self.assertEqual(3, swaps[2][1]) + + def test1(self): + data = [1, 2, 3, 4, 5] + swaps = get_swaps(data) + self.assertEqual(len(swaps), 0) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3