MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/sys_string_conversions_unittest.cc:22–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20namespace butil {
21
22TEST(SysStrings, SysWideToUTF8) {
23 EXPECT_EQ("Hello, world", SysWideToUTF8(L"Hello, world"));
24 EXPECT_EQ("\xe4\xbd\xa0\xe5\xa5\xbd", SysWideToUTF8(L"\x4f60\x597d"));
25
26 // >16 bits
27 EXPECT_EQ("\xF0\x90\x8C\x80", SysWideToUTF8(kSysWideOldItalicLetterA));
28
29 // Error case. When Windows finds a UTF-16 character going off the end of
30 // a string, it just converts that literal value to UTF-8, even though this
31 // is invalid.
32 //
33 // This is what XP does, but Vista has different behavior, so we don't bother
34 // verifying it:
35 // EXPECT_EQ("\xE4\xBD\xA0\xED\xA0\x80zyxw",
36 // SysWideToUTF8(L"\x4f60\xd800zyxw"));
37
38 // Test embedded NULLs.
39 std::wstring wide_null(L"a");
40 wide_null.push_back(0);
41 wide_null.push_back('b');
42
43 std::string expected_null("a");
44 expected_null.push_back(0);
45 expected_null.push_back('b');
46
47 EXPECT_EQ(expected_null, SysWideToUTF8(wide_null));
48}
49
50TEST(SysStrings, SysUTF8ToWide) {
51 EXPECT_EQ(L"Hello, world", SysUTF8ToWide("Hello, world"));

Callers

nothing calls this directly

Calls 8

SysWideToUTF8Function · 0.85
SysUTF8ToWideFunction · 0.85
SysWideToNativeMBFunction · 0.85
SysNativeMBToWideFunction · 0.85
WideToUTF8Function · 0.85
UTF8ToWideFunction · 0.85
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected