Skip to content

Commit 619f84c

Browse files
committed
还原最朴素的写法
1 parent 8bc418e commit 619f84c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ add_subdirectory(src)
3838

3939
if (LIBIPC_BUILD_TESTS)
4040
set(GOOGLETEST_VERSION 1.10.0)
41-
set(gtest_force_shared_crt $<NOT:$<BOOL:${LIBIPC_USE_STATIC_CRT}>>)
41+
if (LIBIPC_USE_STATIC_CRT)
42+
set(gtest_force_shared_crt OFF)
43+
else()
44+
set(gtest_force_shared_crt ON)
45+
endif()
4246
add_subdirectory(3rdparty/gtest)
4347
add_subdirectory(test)
4448
endif()

test/test_platform.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,18 @@
1010
#include "libipc/platform/to_tchar.h"
1111

1212
TEST(Platform, to_tchar) {
13-
unsigned char const utf8[] = {
14-
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2c, 0x20, 0xe6, 0xb5, 0xa3,
15-
0xe7, 0x8a, 0xb2, 0xe3, 0x82, 0xbd, 0xe9, 0x94, 0x9b, 0xe5, 0xb1, 0xbb, 0xe4, 0xba, 0xbe, 0xe9,
16-
0x8a, 0x88, 0xe6, 0x92, 0xb1, 0xe4, 0xbc, 0x80, 0xe9, 0x8a, 0x87, 0xc2, 0xb0, 0xe4, 0xbc, 0x85,
17-
0x00,
18-
};
19-
char const *sstr = reinterpret_cast<char const *>(utf8);
20-
wchar_t const *wstr = reinterpret_cast<wchar_t const *>(u"hello world, 你好,こんにちは");
13+
char const *utf8 = "hello world, "
14+
"\xE6\xB5\xA3\xE7\x8A\xB2\xE3\x82\xBD\xE9\x94\x9B\xE5\xB1\xBB\xE4"
15+
"\xBA\xBE\xE9\x8A\x88\xE6\x92\xB1\xE4\xBC\x80\xE9\x8A\x87\xC2\xB0"
16+
"\xE4\xBC\x85";
17+
wchar_t const *utf16 = L"hello world, \x6D63\x72B2\x30BD\x951B\x5C7B\x4EBE\x9288\x64B1\x4F00\x9287\xB0\x4F05";
2118
{
22-
ipc::string str = ipc::detail::to_tchar<char>(sstr);
23-
EXPECT_STREQ(str.c_str(), sstr);
19+
ipc::string str = ipc::detail::to_tchar<char>(utf8);
20+
EXPECT_STREQ(str.c_str(), utf8);
2421
}
2522
{
26-
ipc::wstring wtr = ipc::detail::to_tchar<wchar_t>(sstr);
27-
EXPECT_STREQ(wtr.c_str(), wstr);
23+
ipc::wstring wtr = ipc::detail::to_tchar<wchar_t>(utf8);
24+
EXPECT_STREQ(wtr.c_str(), utf16);
2825
}
2926
}
3027

0 commit comments

Comments
 (0)