mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-13 22:50:19 +02:00
Fixed #806.
Removed `ss.str().data()` (the type of ss is std::stringstream). Introduced variable that is const reference of `ss.str()`.
This commit is contained in:
@@ -15,7 +15,8 @@ TEST(carray, pack_unpack_int)
|
||||
int v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
int v2[2];
|
||||
@@ -44,7 +45,8 @@ TEST(carray, pack_unpack_const_int)
|
||||
const int v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
int v2[2];
|
||||
@@ -73,7 +75,8 @@ TEST(carray, pack_unpack_string)
|
||||
std::string v1[] = { "ABC", "DEFG" };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
std::string v2[2];
|
||||
@@ -102,7 +105,8 @@ TEST(carray, pack_unpack_char)
|
||||
char v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, msgpack::type::make_array_ref(v1));
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
char v2[2];
|
||||
@@ -118,7 +122,8 @@ TEST(carray, pack_unpack_char_as_str)
|
||||
char v1[2] = { 1, '\0' };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::STR);
|
||||
EXPECT_EQ(oh.get().via.str.size, static_cast<size_t>(1));
|
||||
|
||||
@@ -164,7 +169,8 @@ TEST(carray, pack_unpack_unsigned_char)
|
||||
unsigned char v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, msgpack::type::make_array_ref(v1));
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
unsigned char v2[2];
|
||||
@@ -180,7 +186,8 @@ TEST(carray, pack_unpack_unsigned_char_as_bin)
|
||||
unsigned char v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::BIN);
|
||||
EXPECT_EQ(oh.get().via.bin.size, static_cast<size_t>(2));
|
||||
|
||||
@@ -226,7 +233,8 @@ TEST(carray, pack_unpack_signed_char)
|
||||
signed char v1[] = { 0, 1 };
|
||||
|
||||
msgpack::pack(ss, v1);
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
|
||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||
|
||||
signed char v2[2];
|
||||
|
Reference in New Issue
Block a user