vvellanki commented on a change in pull request #11551:
URL: https://github.com/apache/arrow/pull/11551#discussion_r745840123
##########
File path: cpp/src/gandiva/gdv_function_stubs_test.cc
##########
@@ -766,4 +766,64 @@ TEST(TestGdvFnStubs, TestCastVarbinaryFloat8) {
ctx.Reset();
}
+TEST(TestGdvFnStubs, TestMaskFirstN) {
+ gandiva::ExecutionContext ctx;
+ int64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+ int32_t out_len = 0;
+
+ const char* result = gdv_fn_mask_first_n(ctx_ptr, "0123456789", 10, 10,
&out_len);
+ EXPECT_EQ("nnnnnnnnnn", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26, 26,
&out_len);
+ EXPECT_EQ("XXXXXXXXXXXXXXXXXXXXXXXXXX", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "abcdefghijklmnopqrstuvwxyz", 26, 26,
&out_len);
+ EXPECT_EQ("xxxxxxxxxxxxxxxxxxxxxxxxxx", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "aB-6", 4, 3, &out_len);
+ EXPECT_EQ("xX-6", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "aB-6", 4, -3, &out_len);
+ EXPECT_EQ("aB-6", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "aB-6", 4, 0, &out_len);
+ EXPECT_EQ("aB-6", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "ABcd-123456", 11, 6, &out_len);
+ EXPECT_EQ("XXxx-n23456", std::string(result, out_len));
+
+ result = gdv_fn_mask_first_n(ctx_ptr, "", 0, 6, &out_len);
+ EXPECT_EQ("", std::string(result, out_len));
+}
+
+TEST(TestGdvFnStubs, TestMaskLastN) {
+ gandiva::ExecutionContext ctx;
+ int64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+ int32_t out_len = 0;
+
+ const char* result = gdv_fn_mask_last_n(ctx_ptr, "0123456789", 10, 10,
&out_len);
Review comment:
Please add a test where input length < number of chars to mask
##########
File path: cpp/src/gandiva/gdv_function_stubs_test.cc
##########
@@ -766,4 +766,64 @@ TEST(TestGdvFnStubs, TestCastVarbinaryFloat8) {
ctx.Reset();
}
+TEST(TestGdvFnStubs, TestMaskFirstN) {
+ gandiva::ExecutionContext ctx;
+ int64_t ctx_ptr = reinterpret_cast<int64_t>(&ctx);
+ int32_t out_len = 0;
+
+ const char* result = gdv_fn_mask_first_n(ctx_ptr, "0123456789", 10, 10,
&out_len);
Review comment:
Please add a test where input length < number of chars to mask
--
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]