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

Commit

Permalink
Add unittests for MutableBinaryArray's extend methods
Browse files Browse the repository at this point in the history
  • Loading branch information
VasanthakumarV committed Oct 2, 2021
1 parent 0641563 commit 570a5ab
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/it/array/binary/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,38 @@ fn push_null() {
let array: BinaryArray<i32> = array.into();
assert_eq!(array.validity(), Some(&Bitmap::from([false])));
}

#[test]
fn extend_trusted_len_values() {
let mut array = MutableBinaryArray::<i32>::new();

array.extend_trusted_len_values(vec![b"first".to_vec(), b"second".to_vec()].into_iter());
array.extend_trusted_len_values(vec![b"third".to_vec()].into_iter());
array.extend_trusted_len(vec![None, Some(b"fourth".to_vec())].into_iter());

let array: BinaryArray<i32> = array.into();

assert_eq!(array.values().as_slice(), b"firstsecondthirdfourth");
assert_eq!(array.offsets().as_slice(), &[0, 5, 11, 16, 16, 22]);
assert_eq!(
array.validity(),
Some(&Bitmap::from_u8_slice(&[0b00010111], 5))
);
}

#[test]
fn extend_trusted_len() {
let mut array = MutableBinaryArray::<i32>::new();

array.extend_trusted_len(vec![Some(b"first".to_vec()), Some(b"second".to_vec())].into_iter());
array.extend_trusted_len(vec![None, Some(b"third".to_vec())].into_iter());

let array: BinaryArray<i32> = array.into();

assert_eq!(array.values().as_slice(), b"firstsecondthird");
assert_eq!(array.offsets().as_slice(), &[0, 5, 11, 11, 16]);
assert_eq!(
array.validity(),
Some(&Bitmap::from_u8_slice(&[0b00001011], 4))
);
}

0 comments on commit 570a5ab

Please sign in to comment.