summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHaidong Ji2019-01-10 20:36:29 -0600
committerHaidong Ji2019-01-10 20:36:29 -0600
commitcefc6a2cd763e09adb8b4df33697df4a2cb5ddab (patch)
tree2350644ce1626e8c0271a0a4fa6db78ec904c5fc /tests
parent374f0d359768aa2891b2a6dc24f195f0ec277ab2 (diff)
Tree height done!
Fun exercise. Interesting to experience the mentality change of creating classes in Python, after first creating it in Java. I removed the parent property in Python class since it's not used. Object aliasing caused a bug that took me a bit to figure out.
Diffstat (limited to 'tests')
-rw-r--r--tests/tree_height.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/tree_height.py b/tests/tree_height.py
new file mode 100644
index 0000000..75a1382
--- /dev/null
+++ b/tests/tree_height.py
@@ -0,0 +1,36 @@
+import unittest
+
+from sources.tree_height import get_height
+
+class MyTestCase(unittest.TestCase):
+ def test1(self):
+ a = [4, -1, 4, 1, 1]
+ self.assertEqual(3, get_height(a))
+
+ def test2(self):
+ a = [-1, 0, 4, 0, 3]
+ self.assertEqual(4, get_height(a))
+
+ # def test3(self):
+ # a = [4, -1, 4, 1, 1]
+ # self.assertEqual(3, getHeightNaive(a))
+ #
+ # def test4(self):
+ # a = [-1, 0, 4, 0, 3]
+ # self.assertEqual(4, getHeightNaive(a))
+ #
+ # def test5(self):
+ # a = [9, 7, 5, 5, 2, 9, 9, 9, 2, -1]
+ # self.assertEqual(4, getHeightNaive(a))
+
+ def test6(self):
+ a = [9, 7, 5, 5, 2, 9, 9, 9, 2, -1]
+ self.assertEqual(4, get_height(a))
+
+ def test7(self):
+ a = [8, 8, 5, 6, 7, 3, 1, 6, -1, 5]
+ self.assertEqual(6, get_height(a))
+
+
+if __name__ == '__main__':
+ unittest.main()