MCPcopy Create free account
hub / github.com/apache/arrow / TEST_F

Function TEST_F

cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc:513–591  ·  view source on GitHub ↗

Check two modes exhaustively, give all modes a simple test

Source from the content-addressed store, hash-verified

511
512// Check two modes exhaustively, give all modes a simple test
513TEST_F(TestUnaryRoundArithmeticDecimal, Round) {
514 const auto func = "round";
515 RoundOptions options(2, RoundMode::DOWN);
516 for (const auto& ty : {decimal128(4, 3), decimal256(4, 3)}) {
517 auto values = ArrayFromJSON(
518 ty,
519 R"(["1.010", "1.012", "1.015", "1.019", "-1.010", "-1.012", "-1.015", "-1.019", null])");
520 options.round_mode = RoundMode::DOWN;
521 CheckScalar(
522 func, {values},
523 ArrayFromJSON(
524 ty,
525 R"(["1.010", "1.010", "1.010", "1.010", "-1.010", "-1.020", "-1.020", "-1.020", null])"),
526 &options);
527 options.round_mode = RoundMode::UP;
528 CheckScalar(
529 func, {values},
530 ArrayFromJSON(
531 ty,
532 R"(["1.010", "1.020", "1.020", "1.020", "-1.010", "-1.010", "-1.010", "-1.010", null])"),
533 &options);
534 options.round_mode = RoundMode::TOWARDS_ZERO;
535 CheckScalar(
536 func, {values},
537 ArrayFromJSON(
538 ty,
539 R"(["1.010", "1.010", "1.010", "1.010", "-1.010", "-1.010", "-1.010", "-1.010", null])"),
540 &options);
541 options.round_mode = RoundMode::TOWARDS_INFINITY;
542 CheckScalar(
543 func, {values},
544 ArrayFromJSON(
545 ty,
546 R"(["1.010", "1.020", "1.020", "1.020", "-1.010", "-1.020", "-1.020", "-1.020", null])"),
547 &options);
548 options.round_mode = RoundMode::HALF_DOWN;
549 CheckScalar(
550 func, {values},
551 ArrayFromJSON(
552 ty,
553 R"(["1.010", "1.010", "1.010", "1.020", "-1.010", "-1.010", "-1.020", "-1.020", null])"),
554 &options);
555 options.round_mode = RoundMode::HALF_UP;
556 CheckScalar(
557 func, {values},
558 ArrayFromJSON(
559 ty,
560 R"(["1.010", "1.010", "1.020", "1.020", "-1.010", "-1.010", "-1.010", "-1.020", null])"),
561 &options);
562 options.round_mode = RoundMode::HALF_TOWARDS_ZERO;
563 CheckScalar(
564 func, {values},
565 ArrayFromJSON(
566 ty,
567 R"(["1.010", "1.010", "1.010", "1.020", "-1.010", "-1.010", "-1.010", "-1.020", null])"),
568 &options);
569 options.round_mode = RoundMode::HALF_TOWARDS_INFINITY;
570 CheckScalar(

Callers

nothing calls this directly

Calls 9

decimal256Function · 0.85
ArrayFromJSONFunction · 0.85
CheckScalarFunction · 0.85
DecimalArrayFromJSONFunction · 0.85
ScalarFromJSONFunction · 0.85
decimal128Function · 0.50
Decimal128Function · 0.50
Decimal256Function · 0.50
idMethod · 0.45

Tested by

no test coverage detected