summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
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()