Skip to content

Commit

Permalink
dex: Remove redundant test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyip committed Jun 17, 2022
1 parent c222ac0 commit 86d1b00
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions dex/src/critbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down Expand Up @@ -973,7 +948,7 @@ mod tests {
for i in 0..100_000 {
slab.check_invariants();
let model_state = model.values().collect::<Vec<_>>();
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 {
Expand Down

0 comments on commit 86d1b00

Please sign in to comment.