Skip to content

Commit eca2a10

Browse files
authored
Improve tests for BinaryTree exercise (#2696)
Current tests still pass if `len` is implemented to calculate the height of the tree (i.e. max(left.len(), right.len()) + 1 for each node). It seems this is quite a common misunderstanding when doing this course. With the new assert height implementation will fail, which hints towards implementing `len` as a total number of nodes.
1 parent 53f7660 commit eca2a10

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/smart-pointers/exercise.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ mod tests {
112112
assert_eq!(tree.len(), 2);
113113
tree.insert(2); // not a unique item
114114
assert_eq!(tree.len(), 2);
115+
tree.insert(3);
116+
assert_eq!(tree.len(), 3);
115117
}
116118

117119
#[test]

0 commit comments

Comments
 (0)