mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 20:18:49 +00:00
Fix warnings.
This commit is contained in:
parent
cea08c7abc
commit
35866bb2c2
2
format.h
2
format.h
@ -518,6 +518,7 @@ class UTF8ToUTF16 {
|
||||
explicit UTF8ToUTF16(StringRef s);
|
||||
operator WStringRef() const { return WStringRef(&buffer_[0], size()); }
|
||||
size_t size() const { return buffer_.size() - 1; }
|
||||
std::wstring() const { return std::wstring(&buffer_[0], size()); }
|
||||
};
|
||||
|
||||
// A converter from UTF-16 to UTF-8.
|
||||
@ -531,6 +532,7 @@ class UTF16ToUTF8 {
|
||||
explicit UTF16ToUTF8(WStringRef s);
|
||||
operator StringRef() const { return StringRef(&buffer_[0], size()); }
|
||||
size_t size() const { return buffer_.size() - 1; }
|
||||
std::string() const { return std::string(&buffer_[0], size()); }
|
||||
|
||||
// Performs conversion returning a system error code instead of
|
||||
// throwing exception on error.
|
||||
|
@ -92,14 +92,14 @@ TEST(UtilTest, CountDigits) {
|
||||
TEST(UtilTest, UTF16ToUTF8) {
|
||||
std::string s = "ёжик";
|
||||
fmt::internal::UTF16ToUTF8 u(L"\x0451\x0436\x0438\x043A");
|
||||
EXPECT_EQ(s, fmt::str(u));
|
||||
EXPECT_EQ(s, u.str());
|
||||
EXPECT_EQ(s.size(), u.size());
|
||||
}
|
||||
|
||||
TEST(UtilTest, UTF8ToUTF16) {
|
||||
std::string s = "лошадка";
|
||||
fmt::internal::UTF8ToUTF16 u(s.c_str());
|
||||
EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", fmt::str(u));
|
||||
EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", u.str());
|
||||
EXPECT_EQ(7, u.size());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user