MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_dense_mixed

Function test_dense_mixed

arrow-array/src/array/union_array.rs:1172–1219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1170
1171 #[test]
1172 fn test_dense_mixed() {
1173 let mut builder = UnionBuilder::new_dense();
1174 builder.append::<Int32Type>("a", 1).unwrap();
1175 builder.append::<Int64Type>("c", 3).unwrap();
1176 builder.append::<Int32Type>("a", 4).unwrap();
1177 builder.append::<Int64Type>("c", 5).unwrap();
1178 builder.append::<Int32Type>("a", 6).unwrap();
1179 let union = builder.build().unwrap();
1180
1181 assert_eq!(5, union.len());
1182 for i in 0..union.len() {
1183 let slot = union.value(i);
1184 assert!(!union.is_null(i));
1185 match i {
1186 0 => {
1187 let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
1188 assert_eq!(slot.len(), 1);
1189 let value = slot.value(0);
1190 assert_eq!(1_i32, value);
1191 }
1192 1 => {
1193 let slot = slot.as_any().downcast_ref::<Int64Array>().unwrap();
1194 assert_eq!(slot.len(), 1);
1195 let value = slot.value(0);
1196 assert_eq!(3_i64, value);
1197 }
1198 2 => {
1199 let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
1200 assert_eq!(slot.len(), 1);
1201 let value = slot.value(0);
1202 assert_eq!(4_i32, value);
1203 }
1204 3 => {
1205 let slot = slot.as_any().downcast_ref::<Int64Array>().unwrap();
1206 assert_eq!(slot.len(), 1);
1207 let value = slot.value(0);
1208 assert_eq!(5_i64, value);
1209 }
1210 4 => {
1211 let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap();
1212 assert_eq!(slot.len(), 1);
1213 let value = slot.value(0);
1214 assert_eq!(6_i32, value);
1215 }
1216 _ => unreachable!(),
1217 }
1218 }
1219 }
1220
1221 #[test]
1222 fn test_dense_mixed_with_nulls() {

Callers

nothing calls this directly

Calls 4

buildMethod · 0.45
lenMethod · 0.45
valueMethod · 0.45
as_anyMethod · 0.45

Tested by

no test coverage detected