forked from RoaringBitmap/roaring-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
237: contains_range / range_cardinality functions r=Kerollmops a=Dr-Emann Fixes RoaringBitmap#235 Co-authored-by: Zachary Dremann <dremann@gmail.com>
- Loading branch information
Showing
6 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use proptest::array::uniform2; | ||
use proptest::collection::vec; | ||
use proptest::prelude::*; | ||
use roaring::RoaringBitmap; | ||
|
||
proptest! { | ||
#[test] | ||
fn proptest_range( | ||
range in uniform2(..=262_143_u32), | ||
extra in vec(..=262_143_u32, ..=100), | ||
){ | ||
let range = range[0]..range[1]; | ||
let mut bitmap = RoaringBitmap::new(); | ||
bitmap.insert_range(range.clone()); | ||
assert!(bitmap.contains_range(range.clone())); | ||
assert_eq!(bitmap.range_cardinality(range.clone()) as usize, range.len()); | ||
|
||
for &val in &extra { | ||
bitmap.insert(val); | ||
assert!(bitmap.contains_range(range.clone())); | ||
assert_eq!(bitmap.range_cardinality(range.clone()) as usize, range.len()); | ||
} | ||
|
||
for (i, &val) in extra.iter().filter(|x| range.contains(x)).enumerate() { | ||
bitmap.remove(val); | ||
assert!(!bitmap.contains_range(range.clone())); | ||
assert_eq!(bitmap.range_cardinality(range.clone()) as usize, range.len() - i - 1); | ||
} | ||
} | ||
} |