From b112e7e3f5439c0f4379d9aa92b06680fd4871d9 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 | 7 ++++--- fuzz/fuzz_targets/arbitrary_ops64/mod.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/croaring/src/treemap/iter.rs b/croaring/src/treemap/iter.rs index d25504a..f339fc5 100644 --- a/croaring/src/treemap/iter.rs +++ b/croaring/src/treemap/iter.rs @@ -17,10 +17,11 @@ impl<'a> Iterator for To64Iter<'a> { } } -fn to64iter<'a>(t: (&'a u32, &'a Bitmap)) -> To64Iter<'a> { +fn to64iter<'a>((key, bitmap): (&'a u32, &'a Bitmap)) -> To64Iter<'a> { + assert!(!bitmap.is_empty(), "empty bitmap at {key}"); To64Iter { - key: *t.0, - iterator: t.1.iter(), + key: *key, + iterator: bitmap.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?") } }