std::vector<unsigned char> and std::array<unsigned char> are mapped to BIN.
std::vector<uint8_t> and std::array<uint8_t> are mapped to BIN if uint8_t is the same type of unsigned char, otherwise mapped to ARRAY.

Added array_ref. When client wraps BIN mapped types above with array_ref as msgpack::type::array_ref<std::vector<char> >, the type is mapped to ARRAY.
This commit is contained in:
Takatoshi Kondo
2015-08-31 13:45:59 +09:00
parent 9ee1168cc4
commit 96f145812f
13 changed files with 833 additions and 0 deletions

View File

@@ -93,6 +93,24 @@ TEST(MSGPACK_CPP11, simple_buffer_array_char)
}
}
TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
for (unsigned int k = 0; k < kLoop; k++) {
array<unsigned char, kElements> val1;
for (unsigned int i = 0; i < kElements; i++)
val1[i] = rand();
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::BIN);
array<unsigned char, kElements> val2 = ret.get().as<array<unsigned char, kElements> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
}
// strong typedefs
namespace test {