Avoid printing char16_t* and wchar_t to gtest Message
gtest's Message class has a special handler for operator<< of wchar_t*
to convert it to UTF-8, but it doesn't have one for a single wchar_t or
for a char16_t* string. It delegates these to std::stringstream, which
as of a libc++ upgrade, deletes its operator<< for char16_t and
wchar_t. See wg21.link/p1423r3.
Bug: http://b/175635923
Test: m MODULES-IN-bionic
Change-Id: I8307663b72855cfc0b91d7f63993f1f6fe028b8e
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 14a426f..2b48d85 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -935,7 +935,8 @@
size_t expected_alignment = alignof(Type);
if (expected_alignment != 0) {
ASSERT_EQ(0U, (expected_alignment - 1) & reinterpret_cast<uintptr_t>(floating))
- << "Expected alignment " << expected_alignment << " ptr value " << floating;
+ << "Expected alignment " << expected_alignment << " ptr value "
+ << static_cast<void*>(floating);
}
}
diff --git a/tests/wctype_test.cpp b/tests/wctype_test.cpp
index 85a46aa..0f07956 100644
--- a/tests/wctype_test.cpp
+++ b/tests/wctype_test.cpp
@@ -35,20 +35,24 @@
const wchar_t* falses) {
UtfLocale l;
for (const wchar_t* p = trues; *p; ++p) {
- if (!have_dl() && *p > 0x7f) {
- GTEST_LOG_(INFO) << "skipping unicode test " << *p;
+ const wchar_t val_ch = *p;
+ const int val_int = static_cast<int>(val_ch);
+ if (!have_dl() && val_ch > 0x7f) {
+ GTEST_LOG_(INFO) << "skipping unicode test " << val_int;
continue;
}
- EXPECT_TRUE(fn(*p)) << *p;
- EXPECT_TRUE(fn_l(*p, l.l)) << *p;
+ EXPECT_TRUE(fn(val_ch)) << val_int;
+ EXPECT_TRUE(fn_l(val_ch, l.l)) << val_int;
}
for (const wchar_t* p = falses; *p; ++p) {
- if (!have_dl() && *p > 0x7f) {
- GTEST_LOG_(INFO) << "skipping unicode test " << *p;
+ const wchar_t val_ch = *p;
+ const int val_int = static_cast<int>(val_ch);
+ if (!have_dl() && val_ch > 0x7f) {
+ GTEST_LOG_(INFO) << "skipping unicode test " << val_int;
continue;
}
- EXPECT_FALSE(fn(*p)) << *p;
- EXPECT_FALSE(fn_l(*p, l.l)) << *p;
+ EXPECT_FALSE(fn(val_ch)) << val_int;
+ EXPECT_FALSE(fn_l(val_ch, l.l)) << val_int;
}
}