This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c7f6f9
commit d2411bd
Showing
5 changed files
with
84 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
use arrow2::{ | ||
array::{MutableArray, MutableBooleanArray}, | ||
bitmap::MutableBitmap, | ||
}; | ||
use arrow2::array::{MutableArray, MutableBooleanArray}; | ||
|
||
#[test] | ||
fn set() { | ||
let mut a = MutableBooleanArray::from(&[Some(false), Some(true), Some(false)]); | ||
|
||
a.set(1, None); | ||
a.set(0, Some(true)); | ||
assert_eq!( | ||
a, | ||
MutableBooleanArray::from([Some(true), None, Some(false)]) | ||
) | ||
} | ||
|
||
#[test] | ||
fn push() { | ||
let mut a = MutableBooleanArray::new(); | ||
a.push(Some(true)); | ||
a.push(Some(false)); | ||
a.push(None); | ||
assert_eq!(a.len(), 2); | ||
assert!(a.is_valid(0)); | ||
assert!(!a.is_valid(1)); | ||
|
||
assert_eq!(a.values(), &MutableBitmap::from([true, false])); | ||
a.push_null(); | ||
assert_eq!( | ||
a, | ||
MutableBooleanArray::from([Some(true), Some(false), None, None]) | ||
); | ||
} | ||
|
||
#[test] | ||
fn from_trusted_len_iter() { | ||
let iter = std::iter::repeat(true).take(2).map(Some); | ||
let a = MutableBooleanArray::from_trusted_len_iter(iter); | ||
assert_eq!(a.len(), 2); | ||
assert_eq!(a, MutableBooleanArray::from([Some(true), Some(true)])); | ||
} | ||
|
||
#[test] | ||
fn from_iter() { | ||
let iter = std::iter::repeat(true).take(2).map(Some); | ||
let a: MutableBooleanArray = iter.collect(); | ||
assert_eq!(a.len(), 2); | ||
assert_eq!(a, MutableBooleanArray::from([Some(true), Some(true)])); | ||
} |