The existing tests use println! in conditional ifelse branches to print out key metrics of the tree.
This task is to convert this to assert_eq! statements.
We move these tests into suffix_tree.rs because it is a unit test alongside others, and not an integration test.
We add a script to remind us how to not swallow stdout output in cargo test
cargo test -- --nocapture
Printing out the original test and running it with the above, we get
Children of root: ByteVec { buf: RawVec { ptr: 0x134d04270, cap: 8 }, len: 5 }
Number of children root has: 5
Property 1 Test: Root has an alphabet sized number of children and therefore passes property 1..
This test checks that the root node is at index 1 (implementation detail), that the alphabet length of the given string is 5, and that the number of children of root in the built suffix tree is also 5.
The existing tests use
println!
in conditionalif
else
branches to print out key metrics of the tree. This task is to convert this toassert_eq!
statements.We move these tests into
suffix_tree.rs
because it is a unit test alongside others, and not an integration test.We add a script to remind us how to not swallow
stdout
output incargo test
Printing out the original test and running it with the above, we get
This test checks that the root node is at index 1 (implementation detail), that the alphabet length of the given string is 5, and that the number of children of root in the built suffix tree is also 5.