Skip to content

Commit

Permalink
test: FromIterator for VariableSizeListArray with nullable child …
Browse files Browse the repository at this point in the history
…array
  • Loading branch information
mbrobbel committed Jul 26, 2023
1 parent aeefe44 commit adc3f3b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ members = ["narrow-derive"]

[package]
name = "narrow"
version= "0.2.2"
version= "0.2.3"
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
47 changes: 47 additions & 0 deletions src/array/variable_size_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,52 @@ mod tests {
assert_eq!(array.0.data.0.data.is_valid(1), Some(true));
assert_eq!(array.0.data.0.data.0.is_null(0), Some(true));
assert_eq!(array.0.data.0.data.0.is_valid(1), Some(true));

let input = vec![
None,
Some(vec![
None,
Some(vec![
None,
Some(vec![None, Some(2), Some(3)]),
Some(vec![None, Some(2), Some(3)]),
]),
Some(vec![None, Some(vec![None, Some(5), Some(6)])]),
]),
];
let array = input.into_iter().collect::<VariableSizeListArray<
VariableSizeListArray<
VariableSizeListArray<FixedSizePrimitiveArray<u8, true>, true>,
true,
>,
true,
>>();
assert_eq!(
array.0.data.0.data.0.data.0.as_ref(),
&[
u8::default(),
2,
3,
u8::default(),
2,
3,
u8::default(),
5,
6
]
);
assert_eq!(array.0.offsets.as_ref(), &[0, 0, 3]);
assert_eq!(array.0.data.0.offsets.as_ref(), &[0, 0, 3, 5]);
assert_eq!(array.0.data.0.data.0.offsets.as_ref(), &[0, 0, 3, 6, 6, 9]);
assert_eq!(array.is_null(0), Some(true));
assert_eq!(array.is_valid(1), Some(true));
assert_eq!(array.0.data.is_null(0), Some(true));
assert_eq!(array.0.data.is_valid(1), Some(true));
assert_eq!(array.0.data.0.data.is_null(0), Some(true));
assert_eq!(array.0.data.0.data.is_valid(1), Some(true));
assert_eq!(array.0.data.0.data.0.is_null(0), Some(true));
assert_eq!(array.0.data.0.data.0.is_valid(1), Some(true));
assert_eq!(array.0.data.0.data.0.data.0.is_null(0), Some(true));
assert_eq!(array.0.data.0.data.0.data.0.is_valid(1), Some(true));
}
}

0 comments on commit adc3f3b

Please sign in to comment.