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

Function test_date

arrow-arith/src/numeric.rs:1619–1646  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1617
1618 #[test]
1619 fn test_date() {
1620 test_date_impl::<Date32Type, _>(Date32Type::from_naive_date);
1621 test_date_impl::<Date64Type, _>(Date64Type::from_naive_date);
1622
1623 let a = Date32Array::from(vec![i32::MIN, i32::MAX, 23, 7684]);
1624 let b = Date32Array::from(vec![i32::MIN, i32::MIN, -2, 45]);
1625 let result = sub(&a, &b).unwrap();
1626 assert_eq!(
1627 result.as_primitive::<DurationSecondType>().values(),
1628 &[0, 371085174288000, 2160000, 660009600]
1629 );
1630
1631 let a = Date64Array::from(vec![4343, 76676, 3434]);
1632 let b = Date64Array::from(vec![3, -5, 5]);
1633 let result = sub(&a, &b).unwrap();
1634 assert_eq!(
1635 result.as_primitive::<DurationMillisecondType>().values(),
1636 &[4340, 76681, 3429]
1637 );
1638
1639 let a = Date64Array::from(vec![i64::MAX]);
1640 let b = Date64Array::from(vec![-1]);
1641 let err = sub(&a, &b).unwrap_err().to_string();
1642 assert_eq!(
1643 err,
1644 "Arithmetic overflow: Overflow happened on: 9223372036854775807 - -1"
1645 );
1646 }
1647
1648 #[test]
1649 fn test_date32_to_naive_date_opt_boundaries() {

Callers

nothing calls this directly

Calls 1

subFunction · 0.85

Tested by

no test coverage detected