From 58a2f4f425f8e57e5d723887c9865134159ad078 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 1 May 2014 07:06:35 -0700 Subject: [PATCH] Test error reporting in UTF16ToUTF8. --- format-test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/format-test.cc b/format-test.cc index ae9af30c..0884344a 100644 --- a/format-test.cc +++ b/format-test.cc @@ -238,6 +238,20 @@ TEST(UtilTest, UTF16ToUTF8) { EXPECT_EQ(s.size(), u.size()); } +TEST(UtilTest, UTF16ToUTF8Error) { + fmt::Writer message; + fmt::internal::FormatWinErrorMessage(message, + ERROR_INVALID_PARAMETER, "cannot convert string from UTF-16 to UTF-8"); + fmt::SystemError error("", 0); + try { + fmt::internal::UTF16ToUTF8 u(0); + } catch (const fmt::SystemError &e) { + error = e; + } + EXPECT_EQ(ERROR_INVALID_PARAMETER, error.error_code()); + EXPECT_EQ(message.str(), error.what()); +} + TEST(UtilTest, UTF8ToUTF16) { std::string s = "лошадка"; fmt::internal::UTF8ToUTF16 u(s.c_str());