Skip to content

Commit d7bb03b

Browse files
committed
Add basic tap_tree_height unit test
Use the descriptor string currently in the unit tests and add a basic test of `tap_tree_height`. Done in preparation for adding a height field to the tap tree.
1 parent 37fea86 commit d7bb03b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/descriptor/tr.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,8 @@ where
713713
#[cfg(test)]
714714
mod tests {
715715
use super::*;
716-
use crate::ForEachKey;
717716

718-
#[test]
719-
fn test_for_each() {
717+
fn descriptor() -> String {
720718
let desc = "tr(acc0, {
721719
multi_a(3, acc10, acc11, acc12), {
722720
and_v(
@@ -729,9 +727,21 @@ mod tests {
729727
)
730728
}
731729
})";
732-
let desc = desc.replace(&[' ', '\n'][..], "");
730+
desc.replace(&[' ', '\n'][..], "")
731+
}
732+
733+
#[test]
734+
fn for_each() {
735+
let desc = descriptor();
733736
let tr = Tr::<String>::from_str(&desc).unwrap();
734737
// Note the last ac12 only has ac and fails the predicate
735738
assert!(!tr.for_each_key(|k| k.starts_with("acc")));
736739
}
740+
741+
#[test]
742+
fn height() {
743+
let desc = descriptor();
744+
let tr = Tr::<String>::from_str(&desc).unwrap();
745+
assert_eq!(tr.tap_tree().as_ref().unwrap().tap_tree_height(), 2);
746+
}
737747
}

0 commit comments

Comments
 (0)