From a236172467c88179f4a3a95888735082d1ea6c95 Mon Sep 17 00:00:00 2001 From: Zachary Dremann Date: Sun, 28 Jan 2024 03:06:27 -0500 Subject: [PATCH] Try to find empty subbitmaps in treemap --- croaring/src/treemap/iter.rs | 6 +++++- fuzz/fuzz_targets/arbitrary_ops64/mod.rs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/croaring/src/treemap/iter.rs b/croaring/src/treemap/iter.rs index d25504a..ef767d1 100644 --- a/croaring/src/treemap/iter.rs +++ b/croaring/src/treemap/iter.rs @@ -39,7 +39,11 @@ pub struct TreemapIterator<'a> { impl<'a> TreemapIterator<'a> { fn new(treemap: &'a Treemap) -> Self { - let iter = treemap.map.iter().flat_map(to64iter as _); + let iter = treemap + .map + .iter() + .inspect(|(key, bitmap)| assert!(!bitmap.is_empty(), "empty bitmap at {key}")) + .flat_map(to64iter as _); TreemapIterator { iter } } diff --git a/fuzz/fuzz_targets/arbitrary_ops64/mod.rs b/fuzz/fuzz_targets/arbitrary_ops64/mod.rs index c923ae2..47b31d9 100644 --- a/fuzz/fuzz_targets/arbitrary_ops64/mod.rs +++ b/fuzz/fuzz_targets/arbitrary_ops64/mod.rs @@ -417,7 +417,7 @@ pub fn assert_64_eq(lhs: &Bitmap64, rhs: &Treemap) { let r = rhs.next().unwrap(); assert_eq!(l, r, "{l} != {r} at {i}"); } - assert!(rhs.next().is_none()); + assert_eq!(rhs.next(), None); panic!("Serialize not equal, but all items equal?") } }