Fix mbrtoc16 reserved range test for musl.
Musl was treating 0xf0 as a valid character in its default locale. I
didn't dig into whether that was a musl bug or whether it was actually
translating whatever extended ASCII character that was into the
correct code point (tbh I don't know what the rule there is either).
Bug: None
Test: ./tests/run-on-host.sh 64 --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh glibc --gtest_filter="uchar.*"
Test: ./tests/run-on-host.sh musl --gtest_filter="uchar.*"
Change-Id: I0845fdee9a016ad67ccff3716129ff29f83a63d7
diff --git a/tests/uchar_test.cpp b/tests/uchar_test.cpp
index d54b015..0114adf 100644
--- a/tests/uchar_test.cpp
+++ b/tests/uchar_test.cpp
@@ -237,9 +237,13 @@
}
TEST(uchar, mbrtoc16_reserved_range) {
- char16_t out;
- ASSERT_EQ(static_cast<size_t>(-1),
- mbrtoc16(&out, "\xf0\x80\xbf\xbf", 6, nullptr));
+ ASSERT_STREQ("C.UTF-8", setlocale(LC_CTYPE, "C.UTF-8"));
+
+ errno = 0;
+ char16_t out = u'\0';
+ EXPECT_EQ(static_cast<size_t>(-1), mbrtoc16(&out, "\xf0\x80\xbf\xbf", 6, nullptr));
+ EXPECT_EQ(u'\0', out);
+ EXPECT_EQ(EILSEQ, errno);
}
TEST(uchar, mbrtoc16_beyond_range) {