Compare commits

...

19 Commits

Author SHA1 Message Date
Takatoshi Kondo
b03902d93b Merge pull request #506 from redboltz/fix_494_user_class
Fixed #494.
2016-07-22 20:21:11 +09:00
Takatoshi Kondo
8a2be5b4e9 Fixed #494.
Added false positive warinig suppression code for user_class.cpp.
2016-07-22 16:00:50 +09:00
Takatoshi Kondo
010acda932 Merge pull request #495 from redboltz/fix_494
Fixed #494
2016-07-05 17:17:59 +09:00
Takatoshi Kondo
c951f58531 Fixed #494
Added warning supression code.
2016-06-30 21:59:12 +09:00
Takatoshi Kondo
e59f6e67a5 Merge pull request #468 from redboltz/ver1.4.2
Updated version number.
2016-05-27 18:08:08 +09:00
Takatoshi Kondo
9a8405bcd7 Updated change log and readme. 2016-05-26 20:27:08 +09:00
Takatoshi Kondo
9eca5a9ff6 Updated version number. 2016-05-26 19:50:07 +09:00
Takatoshi Kondo
8388ced33f Merge pull request #467 from redboltz/bp_441
Backported #441 to cpp-1.4.
2016-05-18 21:59:17 +09:00
Takatoshi Kondo
0dcab0b2b1 Backported #441 to cpp-1.4.
Fixed a pointer operation problem at msgpack::zone::chunk_list::clear().
It was only happened on C++03.
2016-05-18 19:21:52 +09:00
Takatoshi Kondo
7df967142d Merge pull request #439 from redboltz/ver1.4.1
Updated the version to 1.4.1.
2016-03-06 20:30:15 +09:00
Takatoshi Kondo
437400c6fe Updated the version to 1.4.1. 2016-03-06 19:54:33 +09:00
Takatoshi Kondo
ae8de13ab6 Merge pull request #438 from redboltz/bp_436
Backported #436 to version 1.4.0.
2016-03-06 18:49:20 +09:00
Takatoshi Kondo
39433e8588 Merge pull request #437 from redboltz/bp_435
Backported #435 to version 1.4.0.
2016-03-06 18:48:52 +09:00
Takatoshi Kondo
94c9bc2ddc Backported #436 to version 1.4.0. 2016-03-06 14:19:10 +09:00
Takatoshi Kondo
1088aa55af Backported #435 to version 1.4.0. 2016-03-06 13:40:40 +09:00
Takatoshi Kondo
66a5fcf8f1 Merge pull request #428 from redboltz/bp_426_1.4
Backported #426 to version 1.4.0.
2016-02-21 00:04:51 +09:00
Takatoshi Kondo
bb0617bd47 Merge pull request #427 from redboltz/bp_423_to_1.4
Backported #423 to version 1.4.0.
2016-02-21 00:03:54 +09:00
Takatoshi Kondo
f642b70e6a Backported #426 to version 1.4.0. 2016-02-20 19:09:18 +09:00
Takatoshi Kondo
3f4ffb9386 Backported #423 to version 1.4.0. 2016-02-20 18:50:13 +09:00
15 changed files with 483 additions and 26 deletions

View File

@@ -1,3 +1,13 @@
# 2016-05-26 version 1.4.2
* Fix C++03 msgpack::zone::clear() memory access violation bug (#467)
# 2016-03-06 version 1.4.1
* Fix TARGET_OS_IPHONE checking (#436, #438)
* Fix invalid front() call for empty container (#435. #437)
* Fix compile error on g++6 (C++11 only) (#426, #428)
* Fix zone size expansion logic (#423, #427)
# 2016-01-22 version 1.4.0
## << recommended changes >>

View File

@@ -1,7 +1,7 @@
`msgpack` for C/C++
===================
Version 1.4.0 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
Version 1.4.2 [![Build Status](https://travis-ci.org/msgpack/msgpack-c.svg?branch=master)](https://travis-ci.org/msgpack/msgpack-c) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
It's like JSON but small and fast.

View File

@@ -125,6 +125,7 @@ class zone {
::free(c);
c = n;
} else {
m_head = c;
break;
}
}

View File

@@ -36,12 +36,13 @@ namespace type {
public:
using base = std::tuple<Types...>;
using base::base;
tuple() = default;
tuple(tuple const&) = default;
tuple(tuple&&) = default;
template<typename... OtherTypes>
tuple(OtherTypes&&... other):base(std::forward<OtherTypes>(other)...) {}
template<typename... OtherTypes>
tuple(tuple<OtherTypes...> const& other):base(static_cast<std::tuple<OtherTypes...> const&>(other)) {}
template<typename... OtherTypes>

View File

@@ -72,6 +72,7 @@ struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
msgpack::object const& operator()(msgpack::object const& o, type::assoc_vector<K, V, Compare, Alloc>& v) const {
if (o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
v.resize(o.via.map.size);
if (o.via.map.size != 0) {
msgpack::object_kv* p = o.via.map.ptr;
msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size;
std::pair<K, V>* it(&v.front());
@@ -80,6 +81,7 @@ struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
p->val.convert(it->second);
}
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K, V, Compare, Alloc>());
}
return o;
}
};
@@ -194,14 +196,22 @@ struct object_with_zone<std::map<K, V, Compare, Alloc> > {
}
else {
uint32_t size = checked_get_container_size(v.size());
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
msgpack::object_kv* const pend = p + size;
o.via.map.ptr = p;
o.via.map.size = size;
typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin());
do {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
p->key = msgpack::object(it->first, o.zone);
p->val = msgpack::object(it->second, o.zone);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
++p;
++it;
} while(p < pend);

View File

@@ -30,11 +30,29 @@ struct convert<std::vector<char, Alloc> > {
switch (o.type) {
case msgpack::type::BIN:
v.resize(o.via.bin.size);
if (o.via.bin.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
case msgpack::type::STR:
v.resize(o.via.str.size);
if (o.via.str.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
default:
throw msgpack::type_error();
@@ -50,7 +68,9 @@ struct pack<std::vector<char, Alloc> > {
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.pack_bin(size);
if (size != 0) {
o.pack_bin_body(&v.front(), size);
}
return o;
}
@@ -61,7 +81,9 @@ struct object<std::vector<char, Alloc> > {
void operator()(msgpack::object& o, const std::vector<char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
if (size != 0) {
o.via.bin.ptr = &v.front();
}
o.via.bin.size = size;
}
};
@@ -71,11 +93,13 @@ struct object_with_zone<std::vector<char, Alloc> > {
void operator()(msgpack::object::with_zone& o, const std::vector<char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
o.via.bin.size = size;
if (size != 0) {
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.bin.ptr = ptr;
o.via.bin.size = size;
std::memcpy(ptr, &v.front(), size);
}
}
};
} // namespace adaptor

View File

@@ -30,11 +30,29 @@ struct convert<std::vector<unsigned char, Alloc> > {
switch (o.type) {
case msgpack::type::BIN:
v.resize(o.via.bin.size);
if (o.via.bin.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
case msgpack::type::STR:
v.resize(o.via.str.size);
if (o.via.str.size != 0) {
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
}
break;
default:
throw msgpack::type_error();
@@ -50,7 +68,9 @@ struct pack<std::vector<unsigned char, Alloc> > {
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<unsigned char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.pack_bin(size);
if (size != 0) {
o.pack_bin_body(reinterpret_cast<char const*>(&v.front()), size);
}
return o;
}
@@ -61,7 +81,9 @@ struct object<std::vector<unsigned char, Alloc> > {
void operator()(msgpack::object& o, const std::vector<unsigned char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
if (size != 0) {
o.via.bin.ptr = reinterpret_cast<char const*>(&v.front());
}
o.via.bin.size = size;
}
};
@@ -71,11 +93,13 @@ struct object_with_zone<std::vector<unsigned char, Alloc> > {
void operator()(msgpack::object::with_zone& o, const std::vector<unsigned char, Alloc>& v) const {
uint32_t size = checked_get_container_size(v.size());
o.type = msgpack::type::BIN;
o.via.bin.size = size;
if (size != 0) {
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
o.via.bin.ptr = ptr;
o.via.bin.size = size;
std::memcpy(ptr, &v.front(), size);
}
}
};
} // namespace adaptor

View File

@@ -125,6 +125,7 @@ class zone {
::free(c);
c = n;
} else {
m_head = c;
break;
}
}

View File

@@ -186,4 +186,8 @@
# define inline __inline
#endif
#ifdef __APPLE__
# include <TargetConditionals.h>
#endif
#endif /* msgpack/sysdep.h */

View File

@@ -1,3 +1,3 @@
#define MSGPACK_VERSION_MAJOR 1
#define MSGPACK_VERSION_MINOR 4
#define MSGPACK_VERSION_REVISION 0
#define MSGPACK_VERSION_REVISION 2

View File

@@ -74,7 +74,7 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
while(sz < size) {
size_t tmp_sz = sz * 2;
if (tmp_sz <= sz) {
tmp_sz = size;
sz = size;
break;
}
sz = tmp_sz;

View File

@@ -54,6 +54,20 @@ TEST(MSGPACK_STL, simple_buffer_vector)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_empty)
{
typedef vector<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
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_char)
{
typedef vector<char, test::allocator<char> > type;
@@ -72,6 +86,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_char)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_char_empty)
{
typedef vector<char, test::allocator<char> > type;
type val1;
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_unsigned_char)
{
typedef vector<unsigned char, test::allocator<unsigned char> > type;
@@ -90,6 +118,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_unsigned_char_empty)
{
typedef vector<unsigned char, test::allocator<unsigned char> > type;
type val1;
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;
@@ -109,6 +151,21 @@ TEST(MSGPACK_STL, simple_buffer_vector_uint8_t)
}
}
TEST(MSGPACK_STL, simple_buffer_vector_uint8_t_empty)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
typedef vector<uint8_t, test::allocator<uint8_t> > type;
type val1;
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;
@@ -125,6 +182,20 @@ TEST(MSGPACK_STL, simple_buffer_vector_bool)
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_STL, simple_buffer_vector_bool_empty)
{
typedef vector<bool, test::allocator<bool> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
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_assoc_vector)
{
@@ -144,6 +215,19 @@ TEST(MSGPACK_STL, simple_buffer_assoc_vector)
}
}
TEST(MSGPACK_STL, simple_buffer_assoc_vector_empty)
{
typedef msgpack::type::assoc_vector<int, int, test::less<int>, test::allocator<std::pair<int, int> > >type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
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_map)
{
typedef map<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
@@ -161,6 +245,19 @@ TEST(MSGPACK_STL, simple_buffer_map)
}
}
TEST(MSGPACK_STL, simple_buffer_map_empty)
{
typedef map<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
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_deque)
{
typedef deque<int, test::allocator<int> > type;
@@ -178,6 +275,19 @@ TEST(MSGPACK_STL, simple_buffer_deque)
}
}
TEST(MSGPACK_STL, simple_buffer_deque_empty)
{
typedef deque<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
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_list)
{
typedef list<int, test::allocator<int> > type;
@@ -195,6 +305,19 @@ TEST(MSGPACK_STL, simple_buffer_list)
}
}
TEST(MSGPACK_STL, simple_buffer_list_empty)
{
typedef list<int, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
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_set)
{
typedef set<int, test::less<int>, test::allocator<int> > type;
@@ -212,6 +335,19 @@ TEST(MSGPACK_STL, simple_buffer_set)
}
}
TEST(MSGPACK_STL, simple_buffer_set_empty)
{
typedef set<int, test::less<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type 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_pair)
{
for (unsigned int k = 0; k < kLoop; k++) {
@@ -256,6 +392,18 @@ TEST(MSGPACK_STL, simple_buffer_multimap)
}
}
TEST(MSGPACK_STL, simple_buffer_multimap_empty)
{
typedef multimap<int, int, test::less<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_STL, simple_buffer_multiset)
{
typedef multiset<int, test::less<int>, test::allocator<int> > type;
@@ -283,6 +431,18 @@ TEST(MSGPACK_STL, simple_buffer_multiset)
}
}
TEST(MSGPACK_STL, simple_buffer_multiset_empty)
{
typedef multiset<int, test::less<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TUPLE, simple_tuple)
{
msgpack::sbuffer sbuf;
@@ -350,6 +510,18 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_map)
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_map_empty)
{
typedef tr1::unordered_map<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap)
{
typedef tr1::unordered_multimap<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
@@ -379,6 +551,19 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multimap_empty)
{
typedef tr1::unordered_multimap<int, int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#ifdef MSGPACK_HAS_STD_TR1_UNORDERED_SET
@@ -403,6 +588,18 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_set)
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_set_empty)
{
typedef tr1::unordered_set<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset)
{
typedef tr1::unordered_multiset<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
@@ -429,6 +626,19 @@ TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_tr1_unordered_multiset_empty)
{
typedef tr1::unordered_multiset<int, test::tr1_hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#if defined (MSGPACK_HAS_STD_UNORDERED_MAP) || defined (MSGPACK_HAS_STD_UNORDERED_SET)
@@ -469,6 +679,18 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_map)
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_map_empty)
{
typedef unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multimap)
{
typedef unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
@@ -498,6 +720,19 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_multimap)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multimap_empty)
{
typedef unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::allocator<std::pair<const int, int> > > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif
#ifdef MSGPACK_HAS_STD_UNORDERED_SET
@@ -523,6 +758,18 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_set)
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_set_empty)
{
typedef unordered_set<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multiset)
{
typedef unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
@@ -549,4 +796,17 @@ TEST(MSGPACK_TR1, simple_buffer_unordered_multiset)
EXPECT_TRUE(v1 == v2);
}
}
TEST(MSGPACK_TR1, simple_buffer_unordered_multiset_empty)
{
typedef unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::allocator<int> > type;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1.size(), val2.size());
}
#endif

View File

@@ -76,6 +76,19 @@ TEST(MSGPACK_CPP11, simple_array)
}
}
TEST(MSGPACK_CPP11, simple_array_empty)
{
array<int, 0> val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
EXPECT_EQ(ret.get().type, msgpack::type::ARRAY);
array<int, 0> val2 = ret.get().as<array<int, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_CPP11, simple_buffer_array_char)
{
for (unsigned int k = 0; k < kLoop; k++) {
@@ -93,6 +106,19 @@ TEST(MSGPACK_CPP11, simple_buffer_array_char)
}
}
TEST(MSGPACK_CPP11, simple_buffer_array_char_empty)
{
array<char, 0> val1;
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<char, 0> val2 = ret.get().as<array<char, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
@@ -111,6 +137,20 @@ TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
}
}
TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char_empty)
{
if (!msgpack::is_same<uint8_t, unsigned char>::value) return;
array<unsigned char, 0> val1;
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, 0> val2 = ret.get().as<array<unsigned char, 0> >();
EXPECT_EQ(val1.size(), val2.size());
EXPECT_TRUE(equal(val1.begin(), val1.end(), val2.begin()));
}
// strong typedefs
namespace test {
@@ -158,6 +198,18 @@ TEST(MSGPACK_STL, simple_buffer_forward_list)
}
}
TEST(MSGPACK_STL, simple_buffer_forward_list_empty)
{
using type = forward_list<int, test::allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_map)
{
using type = unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
@@ -174,6 +226,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_map)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_map_empty)
{
using type = unordered_map<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_multimap)
{
using type = unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
@@ -194,6 +258,19 @@ TEST(MSGPACK_STL, simple_buffer_unordered_multimap)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_multimap_empty)
{
using type = unordered_multimap<int, int, test::hash<int>, test::equal_to<int>, test::map_allocator<int, int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_set)
{
using type = unordered_set<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
@@ -210,6 +287,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_set)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_set_empty)
{
using type = unordered_set<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type>();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_STL, simple_buffer_unordered_multiset)
{
using type = unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
@@ -226,6 +315,18 @@ TEST(MSGPACK_STL, simple_buffer_unordered_multiset)
}
}
TEST(MSGPACK_STL, simple_buffer_unordered_multiset_empty)
{
using type = unordered_multiset<int, test::hash<int>, test::equal_to<int>, test::set_allocator<int>>;
type val1;
msgpack::sbuffer sbuf;
msgpack::pack(sbuf, val1);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
type val2 = ret.get().as<type >();
EXPECT_EQ(val1, val2);
}
TEST(MSGPACK_USER_DEFINED, simple_buffer_enum_class_member)
{
TestEnumClassMemberClass val1;

View File

@@ -742,7 +742,14 @@ TEST(object_with_zone, user_defined_non_virtual)
msgpack::zone z;
msgpack::object obj(b, z);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
bottom br = obj.as<bottom>();
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
EXPECT_EQ(b.b, br.b);
EXPECT_EQ(b.m1, br.m1);
EXPECT_EQ(b.m2, br.m2);
@@ -780,7 +787,14 @@ TEST(object_with_zone, user_defined_virtual)
msgpack::zone z;
msgpack::object obj(b, z);
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
v_bottom br = obj.as<v_bottom>();
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
EXPECT_EQ(b.b, br.b);
EXPECT_EQ(b.m1, br.m1);
EXPECT_EQ(b.m2, br.m2);

View File

@@ -382,7 +382,14 @@ TEST(MSGPACK_INHERIT, define_map_non_virtual)
msgpack::pack(sbuf, b);
msgpack::unpacked ret;
msgpack::unpack(ret, sbuf.data(), sbuf.size());
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
dm_bottom br = ret.get().as<dm_bottom>();
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && !defined(__clang__)
EXPECT_EQ(b.b, br.b);
EXPECT_EQ(b.m1, br.m1);
EXPECT_EQ(b.m2, br.m2);