ikrommyd commented on code in PR #55771:
URL: https://github.com/apache/arrow/pull/55771#discussion_r4758779284
##########
cpp/src/arrow/compute/kernels/scalar_string_test.cc:
##########
@@ -2011,6 +2040,48 @@ TYPED_TEST(TestStringKernels,
SplitWhitespaceUTF8Reverse) {
"[[\"foo\", \"bar\"], [\"foo\xe2\x80\x88 bar\", \"ba\"]]",
&options_max);
}
+
+TYPED_TEST(TestStringKernels, SplitWhitespaceUTF8LeadingTrailing) {
+ SplitOptions options;
+ SplitOptions options_max{1};
+ SplitOptions options_reverse{-1, /*reverse=*/true};
+ SplitOptions options_reverse_max{1, /*reverse=*/true};
+ // \xe2\x80\x88 is punctuation space
+ const char* input =
+ "[\"foo \", \" foo\", \" foo \", \" \", \" \", \"\", "
+ "\"foo\xe2\x80\x88\xe2\x80\x88\", \"\xe2\x80\x88 foo\"]";
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["foo", ""], ["", "foo"], ["", "foo", ""], ["", ""],
["", ""],
+ [""], ["foo", ""], ["", "foo"]])",
+ &options);
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["foo", ""], ["", "foo"], ["", "foo "], ["", ""], ["",
""],
+ [""], ["foo", ""], ["", "foo"]])",
+ &options_max);
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["foo", ""], ["", "foo"], ["", "foo", ""], ["", ""],
["", ""],
+ [""], ["foo", ""], ["", "foo"]])",
+ &options_reverse);
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["foo", ""], ["", "foo"], [" foo", ""], ["", ""], ["",
""],
+ [""], ["foo", ""], ["", "foo"]])",
+ &options_reverse_max);
+}
+
+TYPED_TEST(TestStringKernels, SplitWhitespaceUTF8StaysInBounds) {
+ SplitOptions options;
+ SplitOptions options_reverse{-1, /*reverse=*/true};
+ auto input = MakeArrayInExactBuffer<TypeParam>({" foo ", " bar "},
"\xff", "\xff");
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["", "foo", ""], ["", "bar", ""]])", &options);
+ this->CheckUnary("utf8_split_whitespace", input, list(this->type()),
+ R"([["", "foo", ""], ["", "bar", ""]])", &options_reverse);
+ input = MakeArrayInExactBuffer<TypeParam>({" foo ", " bar "});
Review Comment:
Done but had to split it in two, otherwise it wouldn't compile.
--
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]