mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-14 06:55:50 +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:
@@ -35,8 +35,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert)
|
||||
val1.f1 = 42;
|
||||
val1.f2 = 123.45;
|
||||
msgpack::pack(ss, val1);
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::unpack(str.data(), str.size());
|
||||
mystruct val2 = oh.get().as<mystruct>();
|
||||
EXPECT_TRUE(val1.f1 == val2.f1);
|
||||
EXPECT_TRUE(fabs(val2.f2 - val1.f2) <= kEPS);
|
||||
@@ -156,8 +157,9 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con)
|
||||
std::stringstream ss;
|
||||
mystruct_no_def_con val1(no_def_con1(1), no_def_con2(2), no_def_con1(3));
|
||||
msgpack::pack(ss, val1);
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::unpack(str.data(), str.size());
|
||||
mystruct_no_def_con val2 = oh.get().as<mystruct_no_def_con>();
|
||||
EXPECT_TRUE(val1 == val2);
|
||||
}
|
||||
@@ -207,8 +209,9 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con_def_con)
|
||||
std::stringstream ss;
|
||||
mystruct_no_def_con_def_con val1(no_def_con1(1), no_def_con2(2), 3);
|
||||
msgpack::pack(ss, val1);
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::unpack(str.data(), str.size());
|
||||
mystruct_no_def_con_def_con val2 = oh.get().as<mystruct_no_def_con_def_con>();
|
||||
EXPECT_TRUE(val1 == val2);
|
||||
}
|
||||
@@ -224,8 +227,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert_pair)
|
||||
std::stringstream ss;
|
||||
std::pair<bool, int> val1(false, 42);
|
||||
msgpack::pack(ss, val1);
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::unpack(str.data(), str.size());
|
||||
std::pair<bool, int> val2 = oh.get().as<std::pair<bool, int> >();
|
||||
EXPECT_TRUE(val1.first == val2.first);
|
||||
EXPECT_TRUE(val1.second == val2.second);
|
||||
@@ -240,8 +244,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert_tuple)
|
||||
std::stringstream ss;
|
||||
std::tuple<bool, int> val1(false, 42);
|
||||
msgpack::pack(ss, val1);
|
||||
std::string const& str = ss.str();
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::unpack(str.data(), str.size());
|
||||
std::tuple<bool, int> val2 = oh.get().as<std::tuple<bool, int> >();
|
||||
EXPECT_TRUE(val1 == val2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user