1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-21 07:27:01 +02:00

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.
This commit is contained in:
bartoszkp 2025-03-19 21:46:25 +01:00 committed by GitHub
parent 53f7660e9b
commit eca2a10316
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -112,6 +112,8 @@ mod tests {
assert_eq!(tree.len(), 2);
tree.insert(2); // not a unique item
assert_eq!(tree.len(), 2);
tree.insert(3);
assert_eq!(tree.len(), 3);
}
#[test]