Added char* packing support. char* is packed to STR similar as std::string.

See https://github.com/msgpack/msgpack-c/issues/110
This commit is contained in:
Takatoshi Kondo
2014-09-01 22:42:08 +09:00
parent f0a12a23a1
commit 2103c12e05
6 changed files with 98 additions and 1 deletions

View File

@@ -459,6 +459,23 @@ TEST(MSGPACK_STL, simple_buffer_string)
}
}
TEST(MSGPACK_STL, simple_buffer_cstring)
{
for (unsigned int k = 0; k < kLoop; k++) {
string val1;
for (unsigned int i = 0; i < kElements; i++)
val1 += 'a' + rand() % 26;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1.c_str());
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::STR);
string val2 = ret.get().as<string>();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_EQ(val1, val2);
}
}
TEST(MSGPACK_STL, simple_buffer_vector)
{
for (unsigned int k = 0; k < kLoop; k++) {