MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_array

Function test_array

src/repr/src/row.rs:3741–3765  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3739
3740 #[mz_ore::test]
3741 fn test_array() {
3742 // Construct an array using `Row::push_array` and verify that it unpacks
3743 // correctly.
3744 const DIM: ArrayDimension = ArrayDimension {
3745 lower_bound: 2,
3746 length: 2,
3747 };
3748 let mut row = Row::default();
3749 let mut packer = row.packer();
3750 packer
3751 .try_push_array(&[DIM], vec![Datum::Int32(1), Datum::Int32(2)])
3752 .unwrap();
3753 let arr1 = row.unpack_first().unwrap_array();
3754 assert_eq!(arr1.dims().into_iter().collect::<Vec<_>>(), vec![DIM]);
3755 assert_eq!(
3756 arr1.elements().into_iter().collect::<Vec<_>>(),
3757 vec![Datum::Int32(1), Datum::Int32(2)]
3758 );
3759
3760 // Pack a previously-constructed `Datum::Array` and verify that it
3761 // unpacks correctly.
3762 let row = Row::pack_slice(&[Datum::Array(arr1)]);
3763 let arr2 = row.unpack_first().unwrap_array();
3764 assert_eq!(arr1, arr2);
3765 }
3766
3767 #[mz_ore::test]
3768 fn test_multidimensional_array() {

Callers

nothing calls this directly

Calls 6

ArrayClass · 0.85
packerMethod · 0.80
unwrapMethod · 0.80
try_push_arrayMethod · 0.80
unwrap_arrayMethod · 0.80
unpack_firstMethod · 0.80

Tested by

no test coverage detected