felipecrv commented on code in PR #44904:
URL: https://github.com/apache/arrow/pull/44904#discussion_r1866174452


##########
cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc:
##########
@@ -1563,6 +1563,97 @@ TEST_F(TestUnaryArithmeticDecimal, Exp) {
   }
 }
 
+TYPED_TEST(TestUnaryArithmeticUnsigned, Expm1) {
+  auto expm1 = [](const Datum& arg, ArithmeticOptions, ExecContext* ctx) {
+    return Expm1(arg, ctx);
+  };
+  // Empty arrays
+  this->AssertUnaryOp(expm1, "[]", ArrayFromJSON(float64(), "[]"));
+  // Array with nulls
+  this->AssertUnaryOp(expm1, "[null]", ArrayFromJSON(float64(), "[null]"));
+  this->AssertUnaryOp(expm1, this->MakeNullScalar(), 
arrow::MakeNullScalar(float64()));
+  this->AssertUnaryOp(
+      expm1, "[null, 1, 10]",
+      ArrayFromJSON(float64(), "[null, 1.718281828459045, 
22025.465794806718]"));
+  this->AssertUnaryOp(expm1, this->MakeScalar(1),
+                      arrow::MakeScalar<double>(1.718281828459045F));
+}
+
+TYPED_TEST(TestUnaryArithmeticSigned, Expm1) {
+  auto expm1 = [](const Datum& arg, ArithmeticOptions, ExecContext* ctx) {
+    return Expm1(arg, ctx);
+  };
+  // Empty arrays
+  this->AssertUnaryOp(expm1, "[]", ArrayFromJSON(float64(), "[]"));
+  // Array with nulls
+  this->AssertUnaryOp(expm1, "[null]", ArrayFromJSON(float64(), "[null]"));
+  this->AssertUnaryOp(expm1, this->MakeNullScalar(), 
arrow::MakeNullScalar(float64()));
+  this->AssertUnaryOp(expm1, "[-10, -1, 0, null, 1, 10]",
+                      ArrayFromJSON(float64(),
+                                    "[-0.9999546000702375, 
-0.6321205588285577, 0.0, "
+                                    "null, 1.718281828459045, 
22025.465794806718]"));
+  this->AssertUnaryOp(expm1, this->MakeScalar(1),
+                      arrow::MakeScalar<double>(1.718281828459045F));
+}
+
+TYPED_TEST(TestUnaryArithmeticFloating, Expm1) {
+  using CType = typename TestFixture::CType;
+
+  auto min = std::numeric_limits<CType>::lowest();
+  auto max = std::numeric_limits<CType>::max();
+
+  auto expm1 = [](const Datum& arg, ArithmeticOptions, ExecContext* ctx) {
+    return Expm1(arg, ctx);
+  };
+  // Empty arrays
+  this->AssertUnaryOp(expm1, "[]", "[]");
+  // Array with nulls
+  this->AssertUnaryOp(expm1, "[null]", "[null]");
+  this->AssertUnaryOp(expm1, this->MakeNullScalar(), this->MakeNullScalar());
+  this->AssertUnaryOp(expm1, "[-1.0, 0.0, null, 10.0]",
+                      "[-0.6321205588285577, 0.0, null, 22025.465794806718]");
+  // Ordinary arrays (positive, negative, fractional, and zero inputs)
+  this->AssertUnaryOp(
+      expm1, "[-10.0, 0.0, 0.5, 1.0]",

Review Comment:
   I added 0.0 but you're right about the need for other tiny numbers.



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