feat(bitmap): Add bit and for AllocBitMap (#793)

This commit is contained in:
LoGin
2024-04-30 18:45:01 +08:00
committed by GitHub
parent 7401bec5e3
commit 7db6e06354
3 changed files with 45 additions and 0 deletions

View File

@ -643,3 +643,23 @@ fn test_alloc_bitmap_full_128() {
assert_eq!(bitmap.is_full(), false);
assert_eq!(bitmap.is_empty(), true);
}
#[test]
fn test_alloc_bitmap_bitand_128() {
let mut bitmap = AllocBitmap::new(128);
bitmap.set_all(true);
let mut bitmap2 = AllocBitmap::new(128);
bitmap2.set(0, true);
bitmap2.set(1, true);
bitmap2.set(67, true);
let bitmap3 = bitmap & bitmap2;
assert_eq!(bitmap3.len(), 128);
assert_eq!(bitmap3.size(), 16);
assert_eq!(bitmap3.first_index(), Some(0));
assert_eq!(bitmap3.first_false_index(), Some(2));
assert_eq!(bitmap3.last_index(), Some(67));
}