2020-07-11 09:02:32 +08:00
|
|
|
import unittest
|
2015-08-02 22:53:35 +08:00
|
|
|
|
|
|
|
|
2020-07-11 09:02:32 +08:00
|
|
|
class TestHeight(unittest.TestCase):
|
2015-08-02 22:53:35 +08:00
|
|
|
|
|
|
|
def test_height(self):
|
2016-08-14 20:29:25 +08:00
|
|
|
bst = BstHeight(Node(5))
|
2020-07-11 09:02:32 +08:00
|
|
|
self.assertEqual(bst.height(bst.root), 1)
|
2016-08-14 20:29:25 +08:00
|
|
|
bst.insert(2)
|
|
|
|
bst.insert(8)
|
|
|
|
bst.insert(1)
|
|
|
|
bst.insert(3)
|
2020-07-11 09:02:32 +08:00
|
|
|
self.assertEqual(bst.height(bst.root), 3)
|
2015-08-02 22:53:35 +08:00
|
|
|
|
|
|
|
print('Success: test_height')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
test = TestHeight()
|
|
|
|
test.test_height()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-07-11 09:02:32 +08:00
|
|
|
main()
|