lidavidm commented on a change in pull request #12412: URL: https://github.com/apache/arrow/pull/12412#discussion_r810368474
########## 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: Ah, whoops, indeed. -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org