Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

fix bitmap new_trued #1580

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Bitmap {
// just set each byte to u8::MAX
// we will not access data with index >= length
let bytes = vec![0b11111111u8; length.saturating_add(7) / 8];
unsafe { Bitmap::from_inner_unchecked(Arc::new(bytes.into()), 0, length, length) }
unsafe { Bitmap::from_inner_unchecked(Arc::new(bytes.into()), 0, length, 0) }
}

/// Counts the nulls (unset bits) starting from `offset` bits and for `length` bits.
Expand Down
17 changes: 17 additions & 0 deletions tests/it/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ fn as_slice_offset_middle() {
assert_eq!(length, 5);
}

#[test]
fn new_constant() {
let b = Bitmap::new_constant(true, 9);
let (slice, offset, length) = b.as_slice();
assert_eq!(slice, &[0b11111111, 0b1]);
assert_eq!(offset, 0);
assert_eq!(length, 9);
assert_eq!(b.unset_bits(), 0);

let b = Bitmap::new_constant(false, 9);
let (slice, offset, length) = b.as_slice();
assert_eq!(slice, &[0b00000000, 0b0]);
assert_eq!(offset, 0);
assert_eq!(length, 9);
assert_eq!(b.unset_bits(), 9);
}

#[test]
fn debug() {
let b = Bitmap::from([true, true, false, true, true, true, true, true, true]);
Expand Down
Loading