From cefc6a2cd763e09adb8b4df33697df4a2cb5ddab Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Thu, 10 Jan 2019 20:36:29 -0600 Subject: 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. --- tests/tree_height.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/tree_height.py (limited to 'tests') 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() -- cgit v1.2.3