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

Commit

Permalink
fix bitmap new_trued (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dousir9 authored Oct 18, 2023
1 parent 6a4b531 commit 3c61372
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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
19 changes: 19 additions & 0 deletions tests/it/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ 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[0], 0b11111111);
assert!((slice[1] & 0b00000001) > 0);
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[0], 0b00000000);
assert!((slice[1] & 0b00000001) == 0);
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

0 comments on commit 3c61372

Please sign in to comment.