summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaidong Ji2019-02-17 09:35:46 -0600
committerHaidong Ji2019-02-17 09:35:46 -0600
commit602995c859265493dd94996d1626e6de44d512e6 (patch)
tree0784aeb347cb3a6e25eae77007c2fbe1f420f4f8 /tests
parente314d433e66a6177c8a17e3fca5acc59005e1b06 (diff)
Build heap done!
Not too bad, since the Java version has been worked out.
Diffstat (limited to 'tests')
-rw-r--r--tests/build_heapTest.py25
1 files changed, 25 insertions, 0 deletions
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()