Added wstring adaptor.

This commit is contained in:
Takatoshi Kondo
2018-09-12 15:40:28 +09:00
parent 83a82e3eb5
commit 1155babda8
11 changed files with 234 additions and 11 deletions

View File

@@ -614,3 +614,22 @@ TEST(MSGPACK_STL, simple_buffer_non_const_cstring)
EXPECT_EQ(val1, val2);
}
}
TEST(MSGPACK_STL, simple_buffer_wstring)
{
for (unsigned int k = 0; k < kLoop; k++) {
wstring val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += L'a' + rand() % 26;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::object_handle oh =
msgpack::unpack(sbuf.data(), sbuf.size());
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
wstring val2 = oh.get().as<wstring>();
EXPECT_EQ(val1, val2);
wstring val3;
oh.get().convert(val3);
EXPECT_EQ(val1, val3);
}
}

View File

@@ -332,6 +332,17 @@ TEST(object_without_zone, string)
#endif // MSGPACK_DEFAULT_API_VERSION == 1
// wstring
TEST(object_with_zone, wstring)
{
wstring v = L"abc";
msgpack::zone z;
msgpack::object obj(v, z);
EXPECT_EQ(obj.as<wstring>(), v);
v[0] = 'd';
EXPECT_EQ(obj.as<wstring>()[0], L'a');
}
// char*
TEST(object_with_zone, char_ptr)
{