mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-14 06:55:50 +02:00
Fixed #243.
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:
@@ -72,6 +72,43 @@ TEST(MSGPACK_STL, simple_buffer_vector_char)
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char)
|
||||
{
|
||||
typedef vector<unsigned char, test::allocator<unsigned char> > type;
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
type val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1.push_back(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);
|
||||
type const& val2 = ret.get().as<type>();
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_vector_uint8_t)
|
||||
{
|
||||
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
|
||||
typedef vector<uint8_t, test::allocator<uint8_t> > type;
|
||||
for (unsigned int k = 0; k < kLoop; k++) {
|
||||
type val1;
|
||||
for (unsigned int i = 0; i < kElements; i++)
|
||||
val1.push_back(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);
|
||||
type const& val2 = ret.get().as<type>();
|
||||
EXPECT_EQ(val1.size(), val2.size());
|
||||
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(MSGPACK_STL, simple_buffer_vector_bool)
|
||||
{
|
||||
typedef vector<bool, test::allocator<bool> > type;
|
||||
|
Reference in New Issue
Block a user