anthonylouisbsb commented on a change in pull request #10350:
URL: https://github.com/apache/arrow/pull/10350#discussion_r670455134



##########
File path: cpp/src/gandiva/gdv_function_stubs_test.cc
##########
@@ -484,4 +493,53 @@ TEST(TestGdvFnStubs, TestInitCap) {
                   "unexpected byte \\e0 encountered while decoding utf8 
string"));
   ctx.Reset();
 }
+
+TEST(TestGdvFnStubs, TestAbs) {
+  gandiva::ExecutionContext ctx;
+  uint64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+
+  // Abs functions
+  EXPECT_EQ(gdv_fn_abs_int32(ctx_ptr, 0), 0);
+  EXPECT_EQ(gdv_fn_abs_uint32(ctx_ptr, 0), 0);
+  EXPECT_EQ(gdv_fn_abs_int64(ctx_ptr, 0), 0L);
+  EXPECT_EQ(gdv_fn_abs_uint64(ctx_ptr, 0), 0L);
+  VerifyAlmostEquals(gdv_fn_abs_float32(ctx_ptr, 0.0f), abs(0.0f));
+  VerifyAlmostEquals(gdv_fn_abs_float64(ctx_ptr, 0.0), abs(0.0));
+
+  VerifyAlmostEquals(gdv_fn_abs_int32(ctx_ptr, (INT32_MIN + 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_int64(ctx_ptr, (INT32_MIN + 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_float32(ctx_ptr, static_cast<float>(INT32_MIN 
+ 1)),
+                     abs(static_cast<float>(INT32_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_float64(ctx_ptr, static_cast<double>(INT32_MIN 
+ 1)),
+                     abs(static_cast<double>(INT32_MIN + 1)));
+
+  EXPECT_EQ(gdv_fn_abs_int64(ctx_ptr, (INT64_MIN + 1)),
+            abs(static_cast<double>(INT64_MIN + 1)));
+  VerifyAlmostEquals(gdv_fn_abs_float64(ctx_ptr, static_cast<double>(INT64_MIN 
+ 1)),
+                     abs(static_cast<double>(INT64_MIN + 1)));
+

Review comment:
       Tests added




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