lidavidm commented on a change in pull request #12412:
URL: https://github.com/apache/arrow/pull/12412#discussion_r810336338



##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
##########
@@ -3284,6 +3312,35 @@ TYPED_TEST(TestUnaryArithmeticSigned, Log) {
   this->AssertUnaryOpRaises(Log1p, "[-2]", "logarithm of negative number");
 }
 
+TYPED_TEST(TestUnaryArithmeticIntegral, Sqrt) {
+  // Integer arguments promoted to double, sanity check here
+  for (auto check_overflow : {false, true}) {
+    this->SetOverflowCheck(check_overflow);
+    this->AssertUnaryOp(Sqrt, "[1, null]", ArrayFromJSON(float64(), "[1, 
null]"));
+    this->AssertUnaryOp(Sqrt, "[4, null]", ArrayFromJSON(float64(), "[2, 
null]"));
+    this->AssertUnaryOp(Sqrt, "[null, 9]", ArrayFromJSON(float64(), "[null, 
3]"));
+  }
+}
+
+TYPED_TEST(TestUnaryArithmeticFloating, Sqrt) {
+  using CType = typename TestFixture::CType;
+  this->SetNansEqual(true);
+  auto min_val = std::numeric_limits<CType>::min();
+  auto max_val = std::numeric_limits<CType>::max();
+  for (auto check_overflow : {false, true}) {
+    this->SetOverflowCheck(check_overflow);
+    this->AssertUnaryOp(Sqrt, "[1, 2, null, NaN, Inf]",
+                        "[1, 1.414213562, null, NaN, Inf]");
+    this->AssertUnaryOp(Sqrt, min_val, static_cast<CType>(std::sqrt(min_val)));
+    double atol = this->equal_options_.atol();
+    this->equal_options_.atol(max_val / 1e12);
+    this->AssertUnaryOp(Sqrt, max_val, static_cast<CType>(std::sqrt(max_val)));

Review comment:
       If this is proving problematic on MinGW, let's ifdef it out? We can 
check for `__MINGW32__` (which appears to also be defined on 64-bit, 
confusingly)

##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
##########
@@ -3284,6 +3312,35 @@ TYPED_TEST(TestUnaryArithmeticSigned, Log) {
   this->AssertUnaryOpRaises(Log1p, "[-2]", "logarithm of negative number");
 }
 
+TYPED_TEST(TestUnaryArithmeticIntegral, Sqrt) {
+  // Integer arguments promoted to double, sanity check here
+  for (auto check_overflow : {false, true}) {
+    this->SetOverflowCheck(check_overflow);
+    this->AssertUnaryOp(Sqrt, "[1, null]", ArrayFromJSON(float64(), "[1, 
null]"));
+    this->AssertUnaryOp(Sqrt, "[4, null]", ArrayFromJSON(float64(), "[2, 
null]"));
+    this->AssertUnaryOp(Sqrt, "[null, 9]", ArrayFromJSON(float64(), "[null, 
3]"));
+  }
+}
+
+TYPED_TEST(TestUnaryArithmeticFloating, Sqrt) {
+  using CType = typename TestFixture::CType;
+  this->SetNansEqual(true);
+  auto min_val = std::numeric_limits<CType>::min();
+  auto max_val = std::numeric_limits<CType>::max();
+  for (auto check_overflow : {false, true}) {
+    this->SetOverflowCheck(check_overflow);
+    this->AssertUnaryOp(Sqrt, "[1, 2, null, NaN, Inf]",
+                        "[1, 1.414213562, null, NaN, Inf]");
+    this->AssertUnaryOp(Sqrt, min_val, static_cast<CType>(std::sqrt(min_val)));
+    double atol = this->equal_options_.atol();
+    this->equal_options_.atol(max_val / 1e12);
+    this->AssertUnaryOp(Sqrt, max_val, static_cast<CType>(std::sqrt(max_val)));
+    this->equal_options_.atol(atol);

Review comment:
       Note GTest reinitializes the state on each test so there's no need to 
preserve it




-- 
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