Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
aandres committed Mar 13, 2024
1 parent 1de85ef commit 8f65fe5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,24 @@ mod tests {

assert_eq!(results.as_ref(), &expected)
}

#[test]
fn test_convert_timestamps_empty() {
let seconds_field = Arc::new(Field::new("seconds", DataType::Int64, true));
let nanos_field = Arc::new(Field::new("nanos", DataType::Int32, true));

let seconds_array: Arc<dyn Array> =
Arc::new(arrow::array::Int64Array::from(Vec::<i64>::new()));
let nanos_array: Arc<dyn Array> =
Arc::new(arrow::array::Int32Array::from(Vec::<i32>::new()));

let arrays = vec![(seconds_field, seconds_array), (nanos_field, nanos_array)];

let results = convert_timestamps(&arrays);
assert_eq!(results.len(), 0);

let expected: TimestampNanosecondArray =
arrow::array::Int64Array::from(Vec::<i64>::new()).reinterpret_cast();
assert_eq!(results.as_ref(), &expected)
}
}

0 comments on commit 8f65fe5

Please sign in to comment.