js8544 commented on code in PR #36289:
URL: https://github.com/apache/arrow/pull/36289#discussion_r1276113425


##########
cpp/src/arrow/compute/kernels/scalar_round_arithmetic_test.cc:
##########
@@ -1014,21 +1031,70 @@ TYPED_TEST(TestUnaryRoundSigned, Round) {
   this->SetRoundNdigits(0);
   for (const auto& round_mode : kRoundModes) {
     this->SetRoundMode(round_mode);
-    this->AssertUnaryOp(Round, values, ArrayFromJSON(float64(), values));
+    this->AssertUnaryOp(Round, values, ArrayFromJSON(this->type_singleton(), 
values));
   }
 
   // Test different round N-digits for nearest rounding mode
   std::vector<std::pair<int64_t, std::string>> ndigits_and_expected{{
-      {-2, "[0.0, 0.0, -0.0, -100, 100]"},
-      {-1, "[0.0, 0.0, -10, -50, 120]"},
+      {-2, "[0, 0, -0, -100, 100]"},
+      {-1, "[0, 0, -10, -50, 120]"},
       {0, values},
       {1, values},
       {2, values},
   }};
   this->SetRoundMode(RoundMode::HALF_TOWARDS_INFINITY);
   for (const auto& pair : ndigits_and_expected) {
     this->SetRoundNdigits(pair.first);
-    this->AssertUnaryOp(Round, values, ArrayFromJSON(float64(), pair.second));
+    this->AssertUnaryOp(Round, values,
+                        ArrayFromJSON(this->type_singleton(), pair.second));
+  }
+
+  // Test different rounding mode
+  // skip int8 because of its small range
+  if constexpr (!std::is_same_v<TypeParam, Int8Type>) {
+    std::string values("[0, 1, -13, -50, 115, -176, 200, 250]");
+    this->SetRoundNdigits(-2);
+    std::vector<std::pair<RoundMode, std::string>> round_modes_and_expected{{
+        {RoundMode::DOWN, "[0, 0, -100, -100, 100, -200, 200, 200]"},
+        {RoundMode::UP, "[0, 100, -0, -0, 200, -100, 200, 300]"},
+        {RoundMode::TOWARDS_ZERO, "[0, 0, -0, -0, 100, -100, 200, 200]"},
+        {RoundMode::TOWARDS_INFINITY, "[0, 100, -100, -100, 200, -200, 200, 
300]"},
+        {RoundMode::HALF_DOWN, "[0, 0, -0, -100, 100, -200, 200, 200]"},
+        {RoundMode::HALF_UP, "[0, 0, -0, -0, 100, -200, 200, 300]"},
+        {RoundMode::HALF_TOWARDS_ZERO, "[0, 0, -0, -0, 100, -200, 200, 200]"},
+        {RoundMode::HALF_TOWARDS_INFINITY, "[0, 0, -0, -100, 100, -200, 200, 
300]"},
+        {RoundMode::HALF_TO_EVEN, "[0, 0, -0, -0, 100, -200, 200, 200]"},
+        {RoundMode::HALF_TO_ODD, "[0, 0, -0, -100, 100, -200, 200, 300]"},
+    }};
+    for (const auto& pair : round_modes_and_expected) {
+      this->SetRoundMode(pair.first);
+      this->AssertUnaryOp(Round, values,
+                          ArrayFromJSON(this->type_singleton(), pair.second));
+    }
+  }
+
+  // An overly large ndigits would cause an error
+  if constexpr (std::is_same_v<TypeParam, Int8Type>) {

Review Comment:
   Right. The if constexpr is removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to