projjal commented on code in PR #13656:
URL: https://github.com/apache/arrow/pull/13656#discussion_r927527454


##########
cpp/src/gandiva/precompiled/arithmetic_ops_test.cc:
##########
@@ -653,4 +653,32 @@ TEST(TestArithmeticOps, TestFloorFloatDouble) {
   EXPECT_EQ(floor_float64(-2147483647), -2147483647.0);
 }
 
+TEST(TestArithmeticOps, TestSqrtIntFloatDouble) {
+  // sqrt from int32
+  EXPECT_EQ(sqrt_int32(36), 6.0);
+  EXPECT_EQ(sqrt_int32(49), 7.0);
+  EXPECT_EQ(sqrt_int32(64), 8.0);
+  EXPECT_EQ(sqrt_int32(81), 9.0);
+
+  // sqrt from int64
+  EXPECT_EQ(sqrt_int64(4), 2.0);
+  EXPECT_EQ(sqrt_int64(9), 3.0);
+  EXPECT_EQ(sqrt_int64(64), 8.0);
+  EXPECT_EQ(sqrt_int64(81), 9.0);
+
+  // sqrt from floats
+  EXPECT_EQ(sqrt_float32(16.0f), 4.0);
+  EXPECT_EQ(sqrt_float32(49.0f), 7.0);
+  EXPECT_EQ(sqrt_float32(36.0f), 6.0);
+  EXPECT_EQ(sqrt_float32(0.0f), 0.0);
+
+  // sqrt from doubles
+  EXPECT_EQ(sqrt_float64(16.0), 4.0);
+  EXPECT_EQ(sqrt_float64(11.0889), 3.33);
+  EXPECT_EQ(sqrt_float64(1.522756), 1.234);
+  EXPECT_EQ(sqrt_float64(49.0), 7.0);
+  EXPECT_EQ(sqrt_float64(36.0), 6.0);
+  EXPECT_EQ(sqrt_float64(0.0), 0.0);

Review Comment:
   can you add a test case with negative number



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