alamb commented on a change in pull request #1444:
URL: https://github.com/apache/arrow-rs/pull/1444#discussion_r837849871
##########
File path: arrow/src/array/data.rs
##########
@@ -2537,6 +2639,102 @@ mod tests {
.unwrap();
}
+ #[test]
+ #[should_panic(
+ expected = "Need at least 4 bytes in buffers[0] in array of type Union"
+ )]
+ fn test_validate_dense_union_too_few_values() {
+ // not enough type_ids
+ let type_ids = vec![0i8, 1i8];
+ let offsets = vec![0i32, 0i32];
+ run_dense_union_test(type_ids, offsets);
+ }
+
+ #[test]
+ #[should_panic(
+ expected = "Type invariant failure: type id 2 at position 1 invalid.
Expected < 2"
+ )]
+ fn test_validate_dense_union_bad_type_id() {
+ // typeid of 2 is not valid (only 1 and 0)
+ let type_ids = vec![0i8, 1i8, 2i8, 1i8];
+ let offsets = vec![0i32, 0i32, 1i32, 2i32];
+ run_dense_union_test(type_ids, offsets);
+ }
+
+ #[test]
+ #[should_panic(
+ expected = "Type invariant failure: Could not convert type id -1 to
usize in slot 1"
+ )]
+ fn test_validate_dense_union_negative_type_id() {
+ // typeid of -1 is clearly not valid (only 1 and 0)
+ let type_ids = vec![1i8, 0i8, -1i8, 1i8];
+ let offsets = vec![0i32, 0i32, 1i32, 2i32];
+ run_dense_union_test(type_ids, offsets);
+ }
+
+ #[test]
+ #[should_panic(
+ expected = "Offset invariant failure: Could not convert offset -1 at
position 1 to usize"
+ )]
+ fn test_validate_dense_union_negative_offset() {
+ let type_ids = vec![1i8, 0i8, 0i8, 1i8];
+ // offset of -1 is clearly not valid (only 1 and 0)
+ let offsets = vec![0i32, 0i32, -1i32, 2i32];
+ run_dense_union_test(type_ids, offsets);
+ }
+
+ #[test]
+ #[should_panic(
+ expected = "Value at position 1 out of bounds: 10 (child array 0
length is 2"
+ )]
+ fn test_validate_dense_union_invalid_child_offset() {
+ let type_ids = vec![1i8, 0i8, 0i8, 1i8];
+ // child arrays only have 2 and 3 elements each
+ let offsets = vec![0i32, 0i32, 10i32, 2i32];
+ run_dense_union_test(type_ids, offsets);
+ }
+
+ #[test]
+ #[should_panic(
+ expected = "Offset invariant failure: position 2 invalid. 0 should be
>= 1"
+ )]
+ fn test_validate_dense_union_non_increasing_offset() {
Review comment:
Fixed in 276957306d
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]