From 04a2af269957d70ed8da53c8111f296b51b618e1 Mon Sep 17 00:00:00 2001 From: Thomas Ip Date: Sun, 6 Feb 2022 12:45:44 +0800 Subject: [PATCH] dex: Remove redundant test utils --- dex/src/critbit.rs | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/dex/src/critbit.rs b/dex/src/critbit.rs index 18586fae..73ce800b 100644 --- a/dex/src/critbit.rs +++ b/dex/src/critbit.rs @@ -767,31 +767,6 @@ impl Slab { } } - #[cfg(test)] - fn traverse(&self) -> Vec<&LeafNode> { - fn walk_rec<'a>(slab: &'a Slab, sub_root: NodeHandle, buf: &mut Vec<&'a LeafNode>) { - match slab.get(sub_root).unwrap().case().unwrap() { - NodeRef::Leaf(leaf) => { - buf.push(leaf); - } - NodeRef::Inner(inner) => { - walk_rec(slab, inner.children[0], buf); - walk_rec(slab, inner.children[1], buf); - } - } - } - - let mut buf = Vec::with_capacity(self.header().leaf_count as usize); - if let Some(r) = self.root() { - walk_rec(self, r, &mut buf); - } - if buf.len() != buf.capacity() { - self.hexdump(); - } - assert_eq!(buf.len(), buf.capacity()); - buf - } - #[cfg(test)] fn hexdump(&self) { println!("Header:"); @@ -973,7 +948,7 @@ mod tests { for i in 0..100_000 { slab.check_invariants(); let model_state = model.values().collect::>(); - let slab_state = slab.traverse(); + let slab_state: Vec<&LeafNode> = slab.iter(false).collect(); assert_eq!(model_state, slab_state); match weights[dist.sample(&mut rng)].0 {