Skip to content

Commit fe6e8ad

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 edf9373 commit fe6e8ad

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/descriptor/tr.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,8 @@ where
719719
#[cfg(test)]
720720
mod tests {
721721
use super::*;
722-
use crate::ForEachKey;
723722

724-
#[test]
725-
fn test_for_each() {
723+
fn descriptor() -> String {
726724
let desc = "tr(acc0, {
727725
multi_a(3, acc10, acc11, acc12), {
728726
and_v(
@@ -735,9 +733,21 @@ mod tests {
735733
)
736734
}
737735
})";
738-
let desc = desc.replace(&[' ', '\n'][..], "");
736+
desc.replace(&[' ', '\n'][..], "")
737+
}
738+
739+
#[test]
740+
fn for_each() {
741+
let desc = descriptor();
739742
let tr = Tr::<String>::from_str(&desc).unwrap();
740743
// Note the last ac12 only has ac and fails the predicate
741744
assert!(!tr.for_each_key(|k| k.starts_with("acc")));
742745
}
746+
747+
#[test]
748+
fn height() {
749+
let desc = descriptor();
750+
let tr = Tr::<String>::from_str(&desc).unwrap();
751+
assert_eq!(tr.tap_tree().as_ref().unwrap().height(), 2);
752+
}
743753
}

0 commit comments

Comments
 (0)