sgilmore10 commented on code in PR #36167:
URL: https://github.com/apache/arrow/pull/36167#discussion_r1235253664
##########
cpp/src/arrow/util/utf8_util_test.cc:
##########
@@ -397,6 +397,49 @@ TEST(WideStringToUTF8, Basics) {
#endif
}
+TEST(UTF8StringToUTF16, Basics) {
+ auto CheckOk = [](const std::string& s, const std::u16string& expected) ->
void {
+ ASSERT_OK_AND_ASSIGN(std::u16string u16s, UTF8StringToUTF16(s));
+ ASSERT_EQ(u16s, expected);
+ };
+
+ auto CheckInvalid = [](const std::string& s) -> void {
+ ASSERT_RAISES(Invalid, UTF8StringToUTF16(s));
+ };
+
+ CheckOk("", u"");
+ CheckOk("foo", u"foo");
+ CheckOk("h\xc3\xa9h\xc3\xa9", u"h\u00e9h\u00e9");
+ CheckOk("\xf0\x9f\x98\x80", u"\U0001F600");
+ CheckOk("\xf4\x8f\xbf\xbf", u"\U0010FFFF");
+ CheckOk({0, 'x'}, {0, u'x'});
+
+ CheckInvalid("\xff");
+ CheckInvalid("h\xc3");
Review Comment:
Definitely, I can add one in a followup pull request.
--
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]