Fix UTF conversion tests

This commit is contained in:
Victor Zverovich 2014-10-30 13:00:44 -07:00
parent daca48cb15
commit 14984acd27

View File

@ -724,13 +724,13 @@ TEST(UtilTest, UTF8ToUTF16) {
EXPECT_EQ(7, u.size()); EXPECT_EQ(7, u.size());
} }
template <typename Converter> template <typename Converter, typename Char>
void check_utf_conversion_error(const char *message) { void check_utf_conversion_error(const char *message) {
fmt::MemoryWriter out; fmt::MemoryWriter out;
fmt::internal::format_windows_error(out, ERROR_INVALID_PARAMETER, message); fmt::internal::format_windows_error(out, ERROR_INVALID_PARAMETER, message);
fmt::SystemError error(0, ""); fmt::SystemError error(0, "");
try { try {
Converter(0); Converter(fmt::BasicStringRef<Char>(0, 0));
} catch (const fmt::SystemError &e) { } catch (const fmt::SystemError &e) {
error = e; error = e;
} }
@ -739,18 +739,18 @@ void check_utf_conversion_error(const char *message) {
} }
TEST(UtilTest, UTF16ToUTF8Error) { TEST(UtilTest, UTF16ToUTF8Error) {
check_utf_conversion_error<fmt::internal::UTF16ToUTF8>( check_utf_conversion_error<fmt::internal::UTF16ToUTF8, wchar_t>(
"cannot convert string from UTF-16 to UTF-8"); "cannot convert string from UTF-16 to UTF-8");
} }
TEST(UtilTest, UTF8ToUTF16Error) { TEST(UtilTest, UTF8ToUTF16Error) {
check_utf_conversion_error<fmt::internal::UTF8ToUTF16>( check_utf_conversion_error<fmt::internal::UTF8ToUTF16, char>(
"cannot convert string from UTF-8 to UTF-16"); "cannot convert string from UTF-8 to UTF-16");
} }
TEST(UtilTest, UTF16ToUTF8Convert) { TEST(UtilTest, UTF16ToUTF8Convert) {
fmt::internal::UTF16ToUTF8 u; fmt::internal::UTF16ToUTF8 u;
EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(0)); EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::WStringRef(0, 0));
} }
#endif // _WIN32 #endif // _WIN32