siddhantrao23 commented on code in PR #12581:
URL: https://github.com/apache/arrow/pull/12581#discussion_r856247010


##########
cpp/src/gandiva/precompiled/arithmetic_ops_test.cc:
##########
@@ -80,6 +83,35 @@ TEST(TestArithmeticOps, TestMod) {
   EXPECT_FALSE(context.has_error());
 }
 
+TEST(TestArithmeticOps, TestNegativeDecimal) {
+  gandiva::ExecutionContext ctx;
+  int64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+
+  int64_t out_high_bits = 0;
+  uint64_t out_low_bits = 0;
+
+  arrow::Decimal128 input_decimal("-10.5");
+  negative_decimal(ctx_ptr, input_decimal.high_bits(), 
input_decimal.low_bits(), 3, 1, 3,
+                   1, &out_high_bits, &out_low_bits);
+  arrow::Decimal128 output_decimal("10.5");
+  EXPECT_EQ(output_decimal.high_bits(), out_high_bits);
+  EXPECT_EQ(output_decimal.low_bits(), out_low_bits);
+
+  arrow::Decimal128 input_decimal2("10.5");
+  negative_decimal(ctx_ptr, input_decimal2.high_bits(), 
input_decimal2.low_bits(), 3, 1,
+                   3, 1, &out_high_bits, &out_low_bits);
+  arrow::Decimal128 output_decimal2("-10.5");
+  EXPECT_EQ(output_decimal2.high_bits(), out_high_bits);
+  EXPECT_EQ(output_decimal2.low_bits(), out_low_bits);
+
+  arrow::Decimal128 input_decimal3("-23049223942343.532412");
+  negative_decimal(ctx_ptr, input_decimal3.high_bits(), 
input_decimal3.low_bits(), 20, 6,
+                   20, 6, &out_high_bits, &out_low_bits);
+  arrow::Decimal128 output_decimal3("23049223942343.532412");
+  EXPECT_EQ(output_decimal3.high_bits(), out_high_bits);
+  EXPECT_EQ(output_decimal3.low_bits(), out_low_bits);
+}

Review Comment:
   Could you add some unit tests for decimals with different scale/precision? 
Also add one for 0 precision.



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