augustoasilva commented on a change in pull request #11054:
URL: https://github.com/apache/arrow/pull/11054#discussion_r747903317
##########
File path: cpp/src/gandiva/precompiled/string_ops_test.cc
##########
@@ -53,6 +53,70 @@ TEST(TestStringOps, TestAscii) {
EXPECT_EQ(ascii_utf8("999", 3), 57);
}
+TEST(TestStringOps, TestChr) {
+ // CHR
+ gandiva::ExecutionContext ctx;
+ uint64_t ctx_ptr = reinterpret_cast<gdv_int64>(&ctx);
+ int32_t out_len = 0;
+
+ auto out = chr_int32(ctx_ptr, 88, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "X");
+
+ out = chr_int32(ctx_ptr, 65, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "A");
+
+ out = chr_int32(ctx_ptr, 49, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "1");
+
+ out = chr_int32(ctx_ptr, 84, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "T");
+
+ out = chr_int32(ctx_ptr, 340, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "T");
+
+ out = chr_int32(ctx_ptr, -5, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "");
+
+ out = chr_int32(ctx_ptr, -340, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "");
+
+ out = chr_int32(ctx_ptr, 256, &out_len);
+ EXPECT_EQ(std::string(out, out_len), "");
Review comment:
It now returns the '\0' character which represents the NULL character
--
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]