pitrou commented on a change in pull request #10395: URL: https://github.com/apache/arrow/pull/10395#discussion_r646772300
########## File path: cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc ########## @@ -1161,5 +1180,93 @@ TYPED_TEST(TestUnaryArithmeticFloating, AbsoluteValue) { } } +TYPED_TEST(TestUnaryArithmeticSigned, Sign) { + using CType = typename TestFixture::CType; + auto min = std::numeric_limits<CType>::min(); + auto max = std::numeric_limits<CType>::max(); + + for (auto allow_signed_zero : {false, true}) { + this->SetSignedZero(allow_signed_zero); + // Empty array + this->AssertUnaryOp(Sign, "[]", ArrayFromJSON(int8(), "[]")); + // Scalar/arrays with nulls + this->AssertUnaryOp(Sign, "[null]", ArrayFromJSON(int8(), "[null]")); + this->AssertUnaryOp(Sign, "[1, null, -10]", ArrayFromJSON(int8(), "[1, null, -1]")); + // Scalar/arrays with zeros + this->AssertUnaryOp(Sign, "[0]", ArrayFromJSON(int8(), "[0]")); + // Ordinary scalar/arrays (positive inputs) + this->AssertUnaryOp(Sign, "[1, 10, 127]", ArrayFromJSON(int8(), "[1, 1, 1]")); + // Ordinary scalar/arrays (negative inputs) + this->AssertUnaryOp(Sign, "[-1, -10, -127]", ArrayFromJSON(int8(), "[-1, -1, -1]")); + // Min/max + this->AssertUnaryOp(Sign, ArrayFromJSON(this->type_singleton(), MakeArray(min, max)), + ArrayFromJSON(int8(), "[-1, 1]")); + + auto arg = ArrayFromJSON(this->type_singleton(), MakeArray(-1, min, max, 1)); + arg = TweakValidityBit(arg, 1, false); + arg = TweakValidityBit(arg, 2, false); Review comment: These tests which tweak the validity bits by hand are only meaningful if the kernel may return an error, which is not the case here. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org