TheEvergreenStateCollege / bioinformatics

Plant genome sequencing
2 stars 2 forks source link

Taylor's suffix tree property checks as unit tests #49

Closed learner-long-life closed 3 weeks ago

learner-long-life commented 1 month ago

The existing tests use println! in conditional if else 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.