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

Commit

Permalink
Improved coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Aug 18, 2021
1 parent 2e8ba17 commit a1a4688
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/array/boolean/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,7 @@ impl MutableBooleanArray {
P: std::borrow::Borrow<bool>,
I: TrustedLen<Item = Option<P>>,
{
let (validity, values) = unsafe { trusted_len_unzip(iterator) };

let validity = if validity.null_count() > 0 {
Some(validity)
} else {
None
};

Self::from_data(values, validity)
unsafe { Self::from_trusted_len_iter_unchecked(iterator) }
}

/// Creates a [`BooleanArray`] from an falible iterator of trusted length.
Expand Down Expand Up @@ -210,15 +202,7 @@ impl MutableBooleanArray {
P: std::borrow::Borrow<bool>,
I: TrustedLen<Item = std::result::Result<Option<P>, E>>,
{
let (validity, values) = unsafe { try_trusted_len_unzip(iterator)? };

let validity = if validity.null_count() > 0 {
Some(validity)
} else {
None
};

Ok(Self::from_data(values, validity))
unsafe { Self::try_from_trusted_len_iter_unchecked(iterator) }
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/it/array/boolean/mutable.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use arrow2::array::{MutableArray, MutableBooleanArray};
use arrow2::error::Result;

#[test]
fn set() {
Expand Down Expand Up @@ -38,3 +39,10 @@ fn from_iter() {
let a: MutableBooleanArray = iter.collect();
assert_eq!(a, MutableBooleanArray::from([Some(true), Some(true)]));
}

#[test]
fn try_from_trusted_len_iter() {
let iter = std::iter::repeat(Some(true)).take(2).map(Result::Ok);
let a = MutableBooleanArray::try_from_trusted_len_iter(iter).unwrap();
assert_eq!(a, MutableBooleanArray::from([Some(true), Some(true)]));
}

0 comments on commit a1a4688

Please sign in to comment.