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

Function test_try_binary_mut

arrow-arith/src/arity.rs:465–492  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

463
464 #[test]
465 fn test_try_binary_mut() {
466 let a = Int32Array::from(vec![15, 14, 9, 8, 1]);
467 let b = Int32Array::from(vec![Some(1), None, Some(3), None, Some(5)]);
468 let c = try_binary_mut(a, &b, |l, r| Ok(l + r)).unwrap().unwrap();
469
470 let expected = Int32Array::from(vec![Some(16), None, Some(12), None, Some(6)]);
471 assert_eq!(c, expected);
472
473 let a = Int32Array::from(vec![15, 14, 9, 8, 1]);
474 let b = Int32Array::from(vec![1, 2, 3, 4, 5]);
475 let c = try_binary_mut(a, &b, |l, r| Ok(l + r)).unwrap().unwrap();
476 let expected = Int32Array::from(vec![16, 16, 12, 12, 6]);
477 assert_eq!(c, expected);
478
479 let a = Int32Array::from(vec![15, 14, 9, 8, 1]);
480 let b = Int32Array::from(vec![Some(1), None, Some(3), None, Some(5)]);
481 let _ = try_binary_mut(a, &b, |l, r| {
482 if l == 1 {
483 Err(ArrowError::InvalidArgumentError(
484 "got error".parse().unwrap(),
485 ))
486 } else {
487 Ok(l + r)
488 }
489 })
490 .unwrap()
491 .expect_err("should got error");
492 }
493
494 #[test]
495 fn test_try_binary_mut_null_buffer() {

Callers

nothing calls this directly

Calls 2

try_binary_mutFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected