Skip to content

Commit 7c4ddc6

Browse files
committed
test: Add unit tests
1 parent fcf82a1 commit 7c4ddc6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

data_structures/binary_tree/binary_tree_path_sum.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ class BinaryTreePathSum:
5050
>>> tree.right.right = Node(10)
5151
>>> BinaryTreePathSum().path_sum(tree, 8)
5252
2
53+
>>> BinaryTreePathSum().path_sum(None, 0)
54+
0
55+
>>> BinaryTreePathSum().path_sum(tree, 0)
56+
0
57+
58+
The second tree looks like this
59+
60+
>>> tree2 = Node(0)
61+
>>> tree2.left = Node(5)
62+
>>> tree2.right = Node(5)
63+
0
64+
/ \
65+
5 5
66+
>>> BinaryTreePathSum().path_sum(tree, 5)
67+
2
68+
>>> BinaryTreePathSum().path_sum(tree, -1)
69+
0
70+
>>> BinaryTreePathSum().path_sum(tree, 0)
71+
1
72+
5373
"""
5474

5575
target: int

0 commit comments

Comments
 (0)