Skip to content

Commit

Permalink
Add Duration
Browse files Browse the repository at this point in the history
  • Loading branch information
chmp committed Oct 8, 2024
1 parent 6fdc9d9 commit d64db75
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions marrow/src/_with_latest_arrow/test/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,133 @@ mod time64_nanosecond {
}
}

mod duration_second {
use super::*;

#[test]
fn not_nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationSecondArray>(vec![1, 2, 3]),
Array::Duration(TimeArray {
unit: TimeUnit::Second,
validity: None,
values: vec![1, 2, 3],
}),
)
}

#[test]
fn nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationSecondArray>(vec![None, None, Some(3), Some(4)]),
Array::Duration(TimeArray {
unit: TimeUnit::Second,
validity: Some(vec![0b_1100]),
values: vec![0, 0, 3, 4],
}),
)
}
}

mod duration_millisecond {
use super::*;

#[test]
fn not_nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationMillisecondArray>(vec![1, 2, 3]),
Array::Duration(TimeArray {
unit: TimeUnit::Millisecond,
validity: None,
values: vec![1, 2, 3],
}),
)
}

#[test]
fn nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationMillisecondArray>(vec![
None,
None,
Some(3),
Some(4),
]),
Array::Duration(TimeArray {
unit: TimeUnit::Millisecond,
validity: Some(vec![0b_1100]),
values: vec![0, 0, 3, 4],
}),
)
}
}

mod duration_microsecond {
use super::*;

#[test]
fn not_nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationMicrosecondArray>(vec![1, 2, 3]),
Array::Duration(TimeArray {
unit: TimeUnit::Microsecond,
validity: None,
values: vec![1, 2, 3],
}),
)
}

#[test]
fn nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationMicrosecondArray>(vec![
None,
None,
Some(3),
Some(4),
]),
Array::Duration(TimeArray {
unit: TimeUnit::Microsecond,
validity: Some(vec![0b_1100]),
values: vec![0, 0, 3, 4],
}),
)
}
}

mod duration_nanosecond {
use super::*;

#[test]
fn not_nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationNanosecondArray>(vec![1, 2, 3]),
Array::Duration(TimeArray {
unit: TimeUnit::Nanosecond,
validity: None,
values: vec![1, 2, 3],
}),
)
}

#[test]
fn nullable() -> PanicOnError<()> {
assert_arrays_eq(
as_array_ref::<arrow::array::DurationNanosecondArray>(vec![
None,
None,
Some(3),
Some(4),
]),
Array::Duration(TimeArray {
unit: TimeUnit::Nanosecond,
validity: Some(vec![0b_1100]),
values: vec![0, 0, 3, 4],
}),
)
}
}

mod utf8 {
use super::*;

Expand Down

0 comments on commit d64db75

Please sign in to comment.