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

Function test_boxed_map_builder

arrow-array/src/builder/map_builder.rs:338–377  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

336
337 #[test]
338 fn test_boxed_map_builder() {
339 let keys_builder = make_builder(&DataType::Utf8, 5);
340 let values_builder = make_builder(&DataType::Int32, 5);
341
342 let mut builder = MapBuilder::new(None, keys_builder, values_builder);
343 builder
344 .keys()
345 .as_any_mut()
346 .downcast_mut::<StringBuilder>()
347 .expect("should be an StringBuilder")
348 .append_value("1");
349 builder
350 .values()
351 .as_any_mut()
352 .downcast_mut::<Int32Builder>()
353 .expect("should be an Int32Builder")
354 .append_value(42);
355 builder.append(true).unwrap();
356
357 let map_array = builder.finish();
358
359 assert_eq!(
360 map_array
361 .keys()
362 .as_any()
363 .downcast_ref::<StringArray>()
364 .expect("should be an StringArray")
365 .value(0),
366 "1"
367 );
368 assert_eq!(
369 map_array
370 .values()
371 .as_any()
372 .downcast_ref::<Int32Array>()
373 .expect("should be an Int32Array")
374 .value(0),
375 42
376 );
377 }
378
379 #[test]
380 fn test_with_values_field() {

Callers

nothing calls this directly

Calls 7

make_builderFunction · 0.85
append_valueMethod · 0.45
as_any_mutMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45
appendMethod · 0.45
finishMethod · 0.45

Tested by

no test coverage detected