mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-21 15:51:44 +02:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8085ab8721 | ||
![]() |
b36e75a42e | ||
![]() |
f17f8d79c4 | ||
![]() |
f89f05b883 | ||
![]() |
bd5f814cb2 | ||
![]() |
bf6cc035c7 | ||
![]() |
a6bf728a5c | ||
![]() |
698a482b67 | ||
![]() |
fbf5b9d74c | ||
![]() |
65c35caab2 | ||
![]() |
ff9f14742b | ||
![]() |
4b4eb83cd1 | ||
![]() |
7761497778 | ||
![]() |
6046d5c666 | ||
![]() |
83eb70d718 | ||
![]() |
70f950ac05 | ||
![]() |
3129326432 | ||
![]() |
799cd15107 | ||
![]() |
942965ee87 | ||
![]() |
a123053823 | ||
![]() |
c7603fbbd1 | ||
![]() |
6954e01338 | ||
![]() |
7e23ec496a | ||
![]() |
bae148bd76 | ||
![]() |
3fcecf7099 | ||
![]() |
7d994630d2 |
19
.travis.yml
19
.travis.yml
@@ -232,6 +232,25 @@ matrix:
|
|||||||
- clang-5.0
|
- clang-5.0
|
||||||
script:
|
script:
|
||||||
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}" GTEST_ROOT="${BASE}/gtest" BOOST_ROOT="${BASE}/boost" CTEST_OUTPUT_ON_FAILURE=1 MSGPACK_SAN="${SAN}" ci/build_regression.sh
|
- CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CMAKE_LIBRARY_PATH="${BASE}" GTEST_ROOT="${BASE}/gtest" BOOST_ROOT="${BASE}/boost" CTEST_OUTPUT_ON_FAILURE=1 MSGPACK_SAN="${SAN}" ci/build_regression.sh
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
env: ACTION="ci/build_cmake_embedded.sh" ARCH="64"
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-multilib
|
||||||
|
- gcc-multilib
|
||||||
|
- gcc-7-multilib
|
||||||
|
- g++-7-multilib
|
||||||
|
- lib32stdc++6-6-dbg
|
||||||
|
- lib32gcc1
|
||||||
|
- libc6-i386
|
||||||
|
- lib32z1-dev
|
||||||
|
- zlib1g-dev
|
||||||
|
- bzip2
|
||||||
|
- libc6-dbg
|
||||||
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
|||||||
|
# 2019-12-10 version 3.2.1
|
||||||
|
* Fix snprintf return value checking (#821)
|
||||||
|
* Remove some warnings (#819)
|
||||||
|
* Fix fbuffer result checking (#812)
|
||||||
|
* Fix temporary object handling (#807)
|
||||||
|
* Improve cmake support (#804)
|
||||||
|
* Fix invalid `int main` parameter (#800)
|
||||||
|
* Improve supporting platform (#797, #817)
|
||||||
|
* Fix ZLIB error handling (#795)
|
||||||
|
* Remove unused variable (#793)
|
||||||
|
* Improve integer overflow checking (#792)
|
||||||
|
|
||||||
# 2019-05-27 version 3.2.0
|
# 2019-05-27 version 3.2.0
|
||||||
|
|
||||||
* Fix invalid include (#783)
|
* Fix invalid include (#783)
|
||||||
|
@@ -181,6 +181,7 @@ ELSE ()
|
|||||||
IF (NOT DEFINED MSGPACK_ENABLE_STATIC)
|
IF (NOT DEFINED MSGPACK_ENABLE_STATIC)
|
||||||
SET (MSGPACK_ENABLE_STATIC ON)
|
SET (MSGPACK_ENABLE_STATIC ON)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
SET (BUILD_SHARED_LIBS ${MSGPACK_ENABLE_SHARED})
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
|
OPTION (MSGPACK_ENABLE_CXX "Enable C++ interface." ON)
|
||||||
@@ -209,8 +210,9 @@ CONFIGURE_FILE (
|
|||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
|
||||||
ADD_LIBRARY (msgpackc SHARED
|
IF (MSGPACK_ENABLE_SHARED OR MSGPACK_ENABLE_STATIC)
|
||||||
|
ADD_LIBRARY (msgpackc
|
||||||
${msgpackc_SOURCES}
|
${msgpackc_SOURCES}
|
||||||
${msgpackc_HEADERS}
|
${msgpackc_HEADERS}
|
||||||
)
|
)
|
||||||
@@ -238,7 +240,7 @@ IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSIO
|
|||||||
)
|
)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_STATIC)
|
IF (MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_STATIC)
|
||||||
ADD_LIBRARY (msgpackc-static STATIC
|
ADD_LIBRARY (msgpackc-static STATIC
|
||||||
${msgpackc_SOURCES}
|
${msgpackc_SOURCES}
|
||||||
${msgpackc_HEADERS}
|
${msgpackc_HEADERS}
|
||||||
@@ -253,11 +255,6 @@ IF (MSGPACK_ENABLE_STATIC)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
IF (NOT MSGPACK_ENABLE_SHARED)
|
|
||||||
# Add alias for subdirectories
|
|
||||||
ADD_LIBRARY (msgpackc ALIAS msgpackc-static)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc")
|
SET_TARGET_PROPERTIES (msgpackc-static PROPERTIES OUTPUT_NAME "msgpackc")
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED)
|
||||||
@@ -291,19 +288,19 @@ IF (MSGPACK_BUILD_TESTS)
|
|||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED OR MSGPACK_ENABLE_STATIC)
|
||||||
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra -DPIC")
|
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra -DPIC")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF (MSGPACK_ENABLE_STATIC)
|
IF (MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_STATIC)
|
||||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra" )
|
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra" )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED OR MSGPACK_ENABLE_STATIC)
|
||||||
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
SET_PROPERTY (TARGET msgpackc APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
IF (MSGPACK_ENABLE_STATIC)
|
IF (MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_STATIC)
|
||||||
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
SET_PROPERTY (TARGET msgpackc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
@@ -337,7 +334,7 @@ IF (MSGPACK_BUILD_EXAMPLES)
|
|||||||
ADD_SUBDIRECTORY (example)
|
ADD_SUBDIRECTORY (example)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_SHARED)
|
IF (MSGPACK_ENABLE_SHARED OR MSGPACK_ENABLE_STATIC)
|
||||||
SET (MSGPACK_INSTALLTARGETS msgpackc)
|
SET (MSGPACK_INSTALLTARGETS msgpackc)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
@@ -345,7 +342,7 @@ IF (MSGPACK_ENABLE_CXX AND ((CMAKE_VERSION VERSION_GREATER 3.0) OR (CMAKE_VERSIO
|
|||||||
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-cxx)
|
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-cxx)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_STATIC)
|
IF (MSGPACK_ENABLE_SHARED AND MSGPACK_ENABLE_STATIC)
|
||||||
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-static)
|
LIST (APPEND MSGPACK_INSTALLTARGETS msgpackc-static)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ $ ./hello
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(void) {
|
int main() {
|
||||||
// serializes multiple objects using msgpack::packer.
|
// serializes multiple objects using msgpack::packer.
|
||||||
msgpack::sbuffer buffer;
|
msgpack::sbuffer buffer;
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ int main(void) {
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(void) {
|
int main() {
|
||||||
// serializes multiple objects into one message containing an array using msgpack::packer.
|
// serializes multiple objects into one message containing an array using msgpack::packer.
|
||||||
msgpack::sbuffer buffer;
|
msgpack::sbuffer buffer;
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public:
|
|||||||
MSGPACK_DEFINE(m_str, m_vec);
|
MSGPACK_DEFINE(m_str, m_vec);
|
||||||
};
|
};
|
||||||
|
|
||||||
int main(void) {
|
int main() {
|
||||||
std::vector<myclass> vec;
|
std::vector<myclass> vec;
|
||||||
// add some elements into vec...
|
// add some elements into vec...
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
`msgpack` for C/C++
|
`msgpack` for C/C++
|
||||||
===================
|
===================
|
||||||
|
|
||||||
Version 3.2.0 [](https://travis-ci.org/msgpack/msgpack-c) [](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
|
Version 3.2.1 [](https://travis-ci.org/msgpack/msgpack-c) [](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/master)
|
||||||
|
|
||||||
It's like JSON but smaller and faster.
|
It's like JSON but smaller and faster.
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ In C++:
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
int main(void)
|
int main()
|
||||||
{
|
{
|
||||||
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
|
msgpack::type::tuple<int, bool, std::string> src(1, true, "example");
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
version: 3.2.0.{build}
|
version: 3.2.1.{build}
|
||||||
|
|
||||||
image:
|
image:
|
||||||
- Visual Studio 2015
|
- Visual Studio 2015
|
||||||
|
@@ -72,4 +72,39 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${ARCH}" != "32" ]
|
||||||
|
then
|
||||||
|
mkdir install-test
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd install-test
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmake -DCMAKE_PREFIX_PATH=`pwd`/../install/usr/local/lib/cmake ../../example/cmake
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
59
ci/build_cmake_embedded.sh
Executable file
59
ci/build_cmake_embedded.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cd example/cmake
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f msgpack-c
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -s ../.. msgpack-c
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir build
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd build
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
cmake -DEXAMPLE_MSGPACK_EMBEDDED=ON ..
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
make example example-static
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
exit $ret
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
@@ -83,7 +83,8 @@ int main() {
|
|||||||
u.address = "Tokyo";
|
u.address = "Tokyo";
|
||||||
msgpack::pack(ss, u);
|
msgpack::pack(ss, u);
|
||||||
|
|
||||||
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());
|
||||||
msgpack::object const& obj = oh.get();
|
msgpack::object const& obj = oh.get();
|
||||||
std::cout << "Unpacked msgpack object." << std::endl;
|
std::cout << "Unpacked msgpack object." << std::endl;
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
|
@@ -1,12 +1,3 @@
|
|||||||
IF (MSGPACK_ENABLE_SHARED)
|
|
||||||
SET (MSGPACK_LIB msgpackc)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
IF (MSGPACK_ENABLE_STATIC)
|
|
||||||
SET (MSGPACK_LIB msgpackc-static)
|
|
||||||
ENDIF ()
|
|
||||||
|
|
||||||
|
|
||||||
LIST (APPEND exec_PROGRAMS
|
LIST (APPEND exec_PROGRAMS
|
||||||
lib_buffer_unpack.c
|
lib_buffer_unpack.c
|
||||||
simple_c.c
|
simple_c.c
|
||||||
@@ -22,7 +13,7 @@ FOREACH (source_file ${exec_PROGRAMS})
|
|||||||
${source_file}
|
${source_file}
|
||||||
)
|
)
|
||||||
TARGET_LINK_LIBRARIES (${source_file_we}
|
TARGET_LINK_LIBRARIES (${source_file_we}
|
||||||
${MSGPACK_LIB}
|
msgpackc
|
||||||
)
|
)
|
||||||
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
|
||||||
|
17
example/cmake/CMakeLists.txt
Normal file
17
example/cmake/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
cmake_minimum_required (VERSION 3.0)
|
||||||
|
project (example)
|
||||||
|
|
||||||
|
if(EXAMPLE_MSGPACK_EMBEDDED)
|
||||||
|
add_subdirectory(msgpack-c)
|
||||||
|
set(msgpack_DIR ${CMAKE_CURRENT_BINARY_DIR}/msgpack-c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(msgpack REQUIRED)
|
||||||
|
|
||||||
|
add_executable (${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/../c/simple_c.c)
|
||||||
|
target_link_libraries(${PROJECT_NAME} msgpackc)
|
||||||
|
|
||||||
|
if(TARGET msgpackc-static)
|
||||||
|
add_executable (${PROJECT_NAME}-static ${CMAKE_CURRENT_LIST_DIR}/../c/simple_c.c)
|
||||||
|
target_link_libraries(${PROJECT_NAME}-static msgpackc-static)
|
||||||
|
endif()
|
@@ -82,10 +82,11 @@ int main() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, my);
|
msgpack::pack(ss, my);
|
||||||
|
|
||||||
print(ss.str());
|
std::string const& str = ss.str();
|
||||||
|
print(str);
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::object obj = oh.get();
|
msgpack::object obj = oh.get();
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
assert(obj.as<my_class>() == my);
|
assert(obj.as<my_class>() == my);
|
||||||
|
@@ -59,8 +59,9 @@ int main() {
|
|||||||
|
|
||||||
print(ss.str());
|
print(ss.str());
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::object obj = oh.get();
|
msgpack::object obj = oh.get();
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
assert(obj.as<my_class>() == my);
|
assert(obj.as<my_class>() == my);
|
||||||
|
@@ -100,10 +100,11 @@ int main() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, my);
|
msgpack::pack(ss, my);
|
||||||
|
|
||||||
print(ss.str());
|
std::string const& str = ss.str();
|
||||||
|
print(str);
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::object obj = oh.get();
|
msgpack::object obj = oh.get();
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
assert(obj.as<my_class>() == my);
|
assert(obj.as<my_class>() == my);
|
||||||
|
@@ -71,7 +71,8 @@ int main() {
|
|||||||
|
|
||||||
print(ss.str());
|
print(ss.str());
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
msgpack::object obj = oh.get();
|
msgpack::object obj = oh.get();
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
|
@@ -31,12 +31,13 @@ int main() {
|
|||||||
std::size_t offset = 0;
|
std::size_t offset = 0;
|
||||||
|
|
||||||
// msgpack array is constructed on z.
|
// msgpack array is constructed on z.
|
||||||
msgpack::object obj = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset);
|
std::string const& ps = ss.str();
|
||||||
|
msgpack::object obj = msgpack::unpack(z, ps.data(), ps.size(), offset);
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
assert(obj.as<std::vector<int> >() == v);
|
assert(obj.as<std::vector<int> >() == v);
|
||||||
|
|
||||||
// msgpack str is constructed on z.
|
// msgpack str is constructed on z.
|
||||||
std::string const& str = msgpack::unpack(z, ss.str().data(), ss.str().size(), offset).as<std::string>();
|
std::string const& str = msgpack::unpack(z, ps.data(), ps.size(), offset).as<std::string>();
|
||||||
std::cout << str << std::endl;
|
std::cout << str << std::endl;
|
||||||
assert(str == s);
|
assert(str == s);
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,8 @@ void tuple() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, t);
|
msgpack::pack(ss, t);
|
||||||
|
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size());
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -49,7 +50,8 @@ void unordered_map() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, m);
|
msgpack::pack(ss, m);
|
||||||
|
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::object obj = oh.get();
|
msgpack::object obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -61,7 +63,8 @@ void unordered_set() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, s);
|
msgpack::pack(ss, s);
|
||||||
|
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size());
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -74,7 +77,8 @@ void forward_list() {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, f);
|
msgpack::pack(ss, f);
|
||||||
|
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size());
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -98,7 +102,8 @@ void combi() {
|
|||||||
std::size_t offset = 0;
|
std::size_t offset = 0;
|
||||||
std::cout << "offset: " << offset << std::endl;
|
std::cout << "offset: " << offset << std::endl;
|
||||||
{
|
{
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size(), offset);
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -106,7 +111,8 @@ void combi() {
|
|||||||
}
|
}
|
||||||
std::cout << "offset: " << offset << std::endl;
|
std::cout << "offset: " << offset << std::endl;
|
||||||
{
|
{
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size(), offset);
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -114,7 +120,8 @@ void combi() {
|
|||||||
}
|
}
|
||||||
std::cout << "offset: " << offset << std::endl;
|
std::cout << "offset: " << offset << std::endl;
|
||||||
{
|
{
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size(), offset);
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -122,7 +129,8 @@ void combi() {
|
|||||||
}
|
}
|
||||||
std::cout << "offset: " << offset << std::endl;
|
std::cout << "offset: " << offset << std::endl;
|
||||||
{
|
{
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size(), offset);
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
@@ -130,7 +138,8 @@ void combi() {
|
|||||||
}
|
}
|
||||||
std::cout << "offset: " << offset << std::endl;
|
std::cout << "offset: " << offset << std::endl;
|
||||||
{
|
{
|
||||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
auto const& str = ss.str();
|
||||||
|
auto oh = msgpack::unpack(str.data(), str.size(), offset);
|
||||||
auto obj = oh.get();
|
auto obj = oh.get();
|
||||||
|
|
||||||
std::cout << obj << std::endl;
|
std::cout << obj << std::endl;
|
||||||
|
@@ -25,7 +25,7 @@ extern "C" {
|
|||||||
|
|
||||||
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
|
static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
|
||||||
{
|
{
|
||||||
return (len == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
#if defined(_MSC_VER) && _MSC_VER <= 1800
|
||||||
# define snprintf(buf, len, format,...) _snprintf_s(buf, len, len, format, __VA_ARGS__)
|
# define snprintf(buf, len, format,...) _snprintf_s(buf, len, _TRUNCATE, format, __VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1600
|
#if defined(_MSC_VER) && _MSC_VER < 1600
|
||||||
|
@@ -113,10 +113,13 @@ struct unpack_array {
|
|||||||
if (n > u.limit().array()) throw msgpack::array_size_overflow("array size overflow");
|
if (n > u.limit().array()) throw msgpack::array_size_overflow("array size overflow");
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
size_t size = n*sizeof(msgpack::object);
|
|
||||||
if (size / sizeof(msgpack::object) != n) {
|
#if SIZE_MAX == UINT_MAX
|
||||||
|
if (n > SIZE_MAX/sizeof(msgpack::object))
|
||||||
throw msgpack::array_size_overflow("array size overflow");
|
throw msgpack::array_size_overflow("array size overflow");
|
||||||
}
|
#endif // SIZE_MAX == UINT_MAX
|
||||||
|
|
||||||
|
size_t size = n*sizeof(msgpack::object);
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
o.via.array.ptr = static_cast<msgpack::object*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -125,6 +128,7 @@ inline void unpack_array_item(msgpack::object& c, msgpack::object const& o)
|
|||||||
{
|
{
|
||||||
#if defined(__GNUC__) && !defined(__clang__)
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
std::memcpy(&c.via.array.ptr[c.via.array.size++], &o, sizeof(msgpack::object));
|
std::memcpy(&c.via.array.ptr[c.via.array.size++], &o, sizeof(msgpack::object));
|
||||||
|
|
||||||
#else /* __GNUC__ && !__clang__ */
|
#else /* __GNUC__ && !__clang__ */
|
||||||
c.via.array.ptr[c.via.array.size++] = o;
|
c.via.array.ptr[c.via.array.size++] = o;
|
||||||
#endif /* __GNUC__ && !__clang__ */
|
#endif /* __GNUC__ && !__clang__ */
|
||||||
@@ -135,10 +139,13 @@ struct unpack_map {
|
|||||||
if (n > u.limit().map()) throw msgpack::map_size_overflow("map size overflow");
|
if (n > u.limit().map()) throw msgpack::map_size_overflow("map size overflow");
|
||||||
o.type = msgpack::type::MAP;
|
o.type = msgpack::type::MAP;
|
||||||
o.via.map.size = 0;
|
o.via.map.size = 0;
|
||||||
size_t size = n*sizeof(msgpack::object_kv);
|
|
||||||
if (size / sizeof(msgpack::object_kv) != n) {
|
#if SIZE_MAX == UINT_MAX
|
||||||
|
if (n > SIZE_MAX/sizeof(msgpack::object_kv))
|
||||||
throw msgpack::map_size_overflow("map size overflow");
|
throw msgpack::map_size_overflow("map size overflow");
|
||||||
}
|
#endif // SIZE_MAX == UINT_MAX
|
||||||
|
|
||||||
|
size_t size = n*sizeof(msgpack::object_kv);
|
||||||
o.via.map.ptr = static_cast<msgpack::object_kv*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
o.via.map.ptr = static_cast<msgpack::object_kv*>(u.zone().allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -69,6 +69,7 @@ public:
|
|||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
return m_data;
|
return m_data;
|
||||||
case Z_OK:
|
case Z_OK:
|
||||||
|
case Z_BUF_ERROR:
|
||||||
if(!expand()) {
|
if(!expand()) {
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
@@ -163,10 +163,13 @@ public:
|
|||||||
obj->via.array.ptr = MSGPACK_NULLPTR;
|
obj->via.array.ptr = MSGPACK_NULLPTR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t size = num_elements*sizeof(msgpack::object);
|
|
||||||
if (size / sizeof(msgpack::object) != num_elements) {
|
#if SIZE_MAX == UINT_MAX
|
||||||
|
if (num_elements > SIZE_MAX/sizeof(msgpack::object))
|
||||||
throw msgpack::array_size_overflow("array size overflow");
|
throw msgpack::array_size_overflow("array size overflow");
|
||||||
}
|
#endif // SIZE_MAX == UINT_MAX
|
||||||
|
|
||||||
|
size_t size = num_elements*sizeof(msgpack::object);
|
||||||
obj->via.array.ptr =
|
obj->via.array.ptr =
|
||||||
static_cast<msgpack::object*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
static_cast<msgpack::object*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object)));
|
||||||
}
|
}
|
||||||
@@ -194,10 +197,12 @@ public:
|
|||||||
obj->via.map.ptr = MSGPACK_NULLPTR;
|
obj->via.map.ptr = MSGPACK_NULLPTR;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t size = num_kv_pairs*sizeof(msgpack::object_kv);
|
|
||||||
if (size / sizeof(msgpack::object_kv) != num_kv_pairs) {
|
#if SIZE_MAX == UINT_MAX
|
||||||
|
if (num_kv_pairs > SIZE_MAX/sizeof(msgpack::object_kv))
|
||||||
throw msgpack::map_size_overflow("map size overflow");
|
throw msgpack::map_size_overflow("map size overflow");
|
||||||
}
|
#endif // SIZE_MAX == UINT_MAX
|
||||||
|
size_t size = num_kv_pairs*sizeof(msgpack::object_kv);
|
||||||
obj->via.map.ptr =
|
obj->via.map.ptr =
|
||||||
static_cast<msgpack::object_kv*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
static_cast<msgpack::object_kv*>(m_zone->allocate_align(size, MSGPACK_ZONE_ALIGNOF(msgpack::object_kv)));
|
||||||
}
|
}
|
||||||
|
@@ -241,8 +241,6 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
|
|||||||
const char* const pe = data + len;
|
const char* const pe = data + len;
|
||||||
const char* n = MSGPACK_NULLPTR;
|
const char* n = MSGPACK_NULLPTR;
|
||||||
|
|
||||||
msgpack::object obj;
|
|
||||||
|
|
||||||
if(m_current == pe) {
|
if(m_current == pe) {
|
||||||
off = static_cast<std::size_t>(m_current - m_start);
|
off = static_cast<std::size_t>(m_current - m_start);
|
||||||
return PARSE_CONTINUE;
|
return PARSE_CONTINUE;
|
||||||
|
@@ -250,8 +250,6 @@ inline parse_return context<VisitorHolder>::execute(const char* data, std::size_
|
|||||||
const char* const pe = data + len;
|
const char* const pe = data + len;
|
||||||
const char* n = MSGPACK_NULLPTR;
|
const char* n = MSGPACK_NULLPTR;
|
||||||
|
|
||||||
msgpack::object obj;
|
|
||||||
|
|
||||||
if(m_current == pe) {
|
if(m_current == pe) {
|
||||||
off = static_cast<std::size_t>(m_current - m_start);
|
off = static_cast<std::size_t>(m_current - m_start);
|
||||||
return PARSE_CONTINUE;
|
return PARSE_CONTINUE;
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define MSGPACK_VERSION_MAJOR 3
|
#define MSGPACK_VERSION_MAJOR 3
|
||||||
#define MSGPACK_VERSION_MINOR 2
|
#define MSGPACK_VERSION_MINOR 2
|
||||||
#define MSGPACK_VERSION_REVISION 0
|
#define MSGPACK_VERSION_REVISION 1
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
#include "zone.h"
|
#include "zone.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if defined(unix) || defined(__unix) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__)
|
#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#else
|
#else
|
||||||
struct iovec {
|
struct iovec {
|
||||||
|
@@ -146,6 +146,7 @@ static inline char* msgpack_zbuffer_flush(msgpack_zbuffer* zbuf)
|
|||||||
case Z_STREAM_END:
|
case Z_STREAM_END:
|
||||||
return zbuf->data;
|
return zbuf->data;
|
||||||
case Z_OK:
|
case Z_OK:
|
||||||
|
case Z_BUF_ERROR:
|
||||||
if(!msgpack_zbuffer_expand(zbuf)) {
|
if(!msgpack_zbuffer_expand(zbuf)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,9 @@
|
|||||||
#
|
#
|
||||||
# ::
|
# ::
|
||||||
#
|
#
|
||||||
# msgpackc-static
|
|
||||||
# msgpackc
|
# msgpackc
|
||||||
|
# msgpackc-cxx
|
||||||
|
# msgpackc-static (optional)
|
||||||
#
|
#
|
||||||
|
|
||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
@@ -16,8 +17,4 @@ include(CMakeFindDependencyMacro)
|
|||||||
|
|
||||||
if(NOT TARGET msgpackc AND NOT TARGET msgpackc-static)
|
if(NOT TARGET msgpackc AND NOT TARGET msgpackc-static)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/msgpack-targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/msgpack-targets.cmake")
|
||||||
|
|
||||||
if(NOT @MSGPACK_ENABLE_SHARED@)
|
|
||||||
add_library(msgpackc ALIAS msgpackc-static)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
@@ -256,7 +256,7 @@ void msgpack_object_print(FILE* out, msgpack_object o)
|
|||||||
|
|
||||||
#define MSGPACK_CHECKED_CALL(ret, func, aux_buffer, aux_buffer_size, ...) \
|
#define MSGPACK_CHECKED_CALL(ret, func, aux_buffer, aux_buffer_size, ...) \
|
||||||
ret = func(aux_buffer, aux_buffer_size, __VA_ARGS__); \
|
ret = func(aux_buffer, aux_buffer_size, __VA_ARGS__); \
|
||||||
if (ret <= 0 || ret > (int)aux_buffer_size) return 0; \
|
if (ret <= 0 || ret >= (int)aux_buffer_size) return 0; \
|
||||||
aux_buffer = aux_buffer + ret; \
|
aux_buffer = aux_buffer + ret; \
|
||||||
aux_buffer_size = aux_buffer_size - ret \
|
aux_buffer_size = aux_buffer_size - ret \
|
||||||
|
|
||||||
|
@@ -25,8 +25,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_char)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::vector<char> v2;
|
std::vector<char> v2;
|
||||||
msgpack::type::array_ref<std::vector<char> > ar2(v2);
|
msgpack::type::array_ref<std::vector<char> > ar2(v2);
|
||||||
@@ -47,8 +48,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_char_const)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::vector<char> v2;
|
std::vector<char> v2;
|
||||||
msgpack::type::array_ref<std::vector<char> > ar2(v2);
|
msgpack::type::array_ref<std::vector<char> > ar2(v2);
|
||||||
@@ -67,8 +69,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::vector<unsigned char> v2;
|
std::vector<unsigned char> v2;
|
||||||
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
|
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
|
||||||
@@ -89,8 +92,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_vector_unsigned_char_const)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::vector<unsigned char> v2;
|
std::vector<unsigned char> v2;
|
||||||
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
|
msgpack::type::array_ref<std::vector<unsigned char> > ar2(v2);
|
||||||
@@ -184,8 +188,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_char)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::array<char, 3> v2;
|
std::array<char, 3> v2;
|
||||||
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
|
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
|
||||||
@@ -203,8 +208,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_char_const)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::array<char, 3> v2;
|
std::array<char, 3> v2;
|
||||||
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
|
msgpack::type::array_ref<std::array<char, 3> > ar2(v2);
|
||||||
@@ -220,8 +226,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::array<unsigned char, 3> v2;
|
std::array<unsigned char, 3> v2;
|
||||||
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
|
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
|
||||||
@@ -239,8 +246,9 @@ TEST(MSGPACK_ARRAY_REF, pack_unpack_convert_array_unsigned_char_const)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, ar1);
|
msgpack::pack(ss, ar1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
std::array<unsigned char, 3> v2;
|
std::array<unsigned char, 3> v2;
|
||||||
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
|
msgpack::type::array_ref<std::array<unsigned char, 3> > ar2(v2);
|
||||||
|
@@ -35,8 +35,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert)
|
|||||||
val1.f1 = 42;
|
val1.f1 = 42;
|
||||||
val1.f2 = 123.45;
|
val1.f2 = 123.45;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
mystruct val2 = oh.get().as<mystruct>();
|
mystruct val2 = oh.get().as<mystruct>();
|
||||||
EXPECT_TRUE(val1.f1 == val2.f1);
|
EXPECT_TRUE(val1.f1 == val2.f1);
|
||||||
EXPECT_TRUE(fabs(val2.f2 - val1.f2) <= kEPS);
|
EXPECT_TRUE(fabs(val2.f2 - val1.f2) <= kEPS);
|
||||||
@@ -156,8 +157,9 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
mystruct_no_def_con val1(no_def_con1(1), no_def_con2(2), no_def_con1(3));
|
mystruct_no_def_con val1(no_def_con1(1), no_def_con2(2), no_def_con1(3));
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
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>();
|
mystruct_no_def_con val2 = oh.get().as<mystruct_no_def_con>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -207,8 +209,9 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
mystruct_no_def_con_def_con val1(no_def_con1(1), no_def_con2(2), 3);
|
mystruct_no_def_con_def_con val1(no_def_con1(1), no_def_con2(2), 3);
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
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>();
|
mystruct_no_def_con_def_con val2 = oh.get().as<mystruct_no_def_con_def_con>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -224,8 +227,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert_pair)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::pair<bool, int> val1(false, 42);
|
std::pair<bool, int> val1(false, 42);
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
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> >();
|
std::pair<bool, int> val2 = oh.get().as<std::pair<bool, int> >();
|
||||||
EXPECT_TRUE(val1.first == val2.first);
|
EXPECT_TRUE(val1.first == val2.first);
|
||||||
EXPECT_TRUE(val1.second == val2.second);
|
EXPECT_TRUE(val1.second == val2.second);
|
||||||
@@ -240,8 +244,9 @@ TEST(MSGPACK_BOOST, fusion_pack_unpack_convert_tuple)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::tuple<bool, int> val1(false, 42);
|
std::tuple<bool, int> val1(false, 42);
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
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> >();
|
std::tuple<bool, int> val2 = oh.get().as<std::tuple<bool, int> >();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,9 @@ TEST(MSGPACK_BOOST, pack_convert_nil)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
boost::optional<int> val1;
|
boost::optional<int> val1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
boost::optional<int> val2 = oh.get().as<boost::optional<int> >();
|
boost::optional<int> val2 = oh.get().as<boost::optional<int> >();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -32,8 +33,9 @@ TEST(MSGPACK_BOOST, pack_convert_int)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
boost::optional<int> val1 = 1;
|
boost::optional<int> val1 = 1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
boost::optional<int> val2 = oh.get().as<boost::optional<int> >();
|
boost::optional<int> val2 = oh.get().as<boost::optional<int> >();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -49,8 +51,9 @@ TEST(MSGPACK_BOOST, pack_convert_vector)
|
|||||||
v.push_back(3);
|
v.push_back(3);
|
||||||
val1 = v;
|
val1 = v;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
ovi_t val2 = oh.get().as<ovi_t>();
|
ovi_t val2 = oh.get().as<ovi_t>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -64,8 +67,9 @@ TEST(MSGPACK_BOOST, pack_convert_vector_optional)
|
|||||||
val1[0] = 1;
|
val1[0] = 1;
|
||||||
val1[2] = 3;
|
val1[2] = 3;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
voi_t val2 = oh.get().as<voi_t>();
|
voi_t val2 = oh.get().as<voi_t>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -171,8 +175,9 @@ TEST(MSGPACK_BOOST, pack_convert_no_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
boost::optional<no_def_con> val1 = no_def_con(1);
|
boost::optional<no_def_con> val1 = no_def_con(1);
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
boost::optional<no_def_con> val2 = oh.get().as<boost::optional<no_def_con>>();
|
boost::optional<no_def_con> val2 = oh.get().as<boost::optional<no_def_con>>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,8 @@ TEST(MSGPACK_BOOST, pack_convert_string_ref)
|
|||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
std::string const& str = ss.str();
|
||||||
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
boost::string_ref val2 = oh.get().as<boost::string_ref>();
|
boost::string_ref val2 = oh.get().as<boost::string_ref>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,8 @@ TEST(MSGPACK_BOOST, pack_convert_string_view)
|
|||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
std::string const& str = ss.str();
|
||||||
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
boost::string_view val2 = oh.get().as<boost::string_view>();
|
boost::string_view val2 = oh.get().as<boost::string_view>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
|
@@ -27,8 +27,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_nil)
|
|||||||
EXPECT_TRUE(val1.is_nil());
|
EXPECT_TRUE(val1.is_nil());
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_nil());
|
EXPECT_TRUE(val2.is_nil());
|
||||||
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
|
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
|
||||||
@@ -65,8 +66,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_nil_default)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_nil());
|
EXPECT_TRUE(val2.is_nil());
|
||||||
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
|
EXPECT_NO_THROW(boost::get<msgpack::type::nil_t>(val2));
|
||||||
@@ -104,8 +106,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_bool)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_bool());
|
EXPECT_TRUE(val2.is_bool());
|
||||||
EXPECT_TRUE(val2.as_bool());
|
EXPECT_TRUE(val2.as_bool());
|
||||||
@@ -157,8 +160,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_positive_integer)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_uint64_t());
|
EXPECT_TRUE(val2.is_uint64_t());
|
||||||
EXPECT_EQ(val2.as_uint64_t(), 123U);
|
EXPECT_EQ(val2.as_uint64_t(), 123U);
|
||||||
@@ -204,8 +208,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_negative_integer)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_int64_t());
|
EXPECT_TRUE(val2.is_int64_t());
|
||||||
EXPECT_EQ(val2.as_int64_t(), -123);
|
EXPECT_EQ(val2.as_int64_t(), -123);
|
||||||
@@ -251,8 +256,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_float)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_double());
|
EXPECT_TRUE(val2.is_double());
|
||||||
EXPECT_TRUE(fabs(12.34 - val2.as_double()) <= kEPS);
|
EXPECT_TRUE(fabs(12.34 - val2.as_double()) <= kEPS);
|
||||||
@@ -298,8 +304,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_str)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_string());
|
EXPECT_TRUE(val2.is_string());
|
||||||
EXPECT_EQ(val2.as_string(), "ABC");
|
EXPECT_EQ(val2.as_string(), "ABC");
|
||||||
@@ -360,8 +367,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_bin)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_vector_char());
|
EXPECT_TRUE(val2.is_vector_char());
|
||||||
EXPECT_EQ(val2.as_vector_char(), v);
|
EXPECT_EQ(val2.as_vector_char(), v);
|
||||||
@@ -431,8 +439,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ext)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_ext());
|
EXPECT_TRUE(val2.is_ext());
|
||||||
EXPECT_EQ(val2.as_ext(), e);
|
EXPECT_EQ(val2.as_ext(), e);
|
||||||
@@ -498,8 +507,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_array)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_vector());
|
EXPECT_TRUE(val2.is_vector());
|
||||||
EXPECT_EQ(val2.as_vector(), v);
|
EXPECT_EQ(val2.as_vector(), v);
|
||||||
@@ -540,8 +550,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_map)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
msgpack::type::variant val2 = oh.get().as<msgpack::type::variant>();
|
||||||
EXPECT_TRUE(val2.is_multimap());
|
EXPECT_TRUE(val2.is_multimap());
|
||||||
EXPECT_EQ(val2.as_multimap(), v);
|
EXPECT_EQ(val2.as_multimap(), v);
|
||||||
@@ -584,8 +595,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_str)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
||||||
EXPECT_TRUE(val2.is_boost_string_ref());
|
EXPECT_TRUE(val2.is_boost_string_ref());
|
||||||
EXPECT_EQ(val2.as_boost_string_ref(), sr);
|
EXPECT_EQ(val2.as_boost_string_ref(), sr);
|
||||||
@@ -629,8 +641,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_bin)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
||||||
EXPECT_TRUE(val2.is_raw_ref());
|
EXPECT_TRUE(val2.is_raw_ref());
|
||||||
EXPECT_EQ(val2.as_raw_ref(), rr);
|
EXPECT_EQ(val2.as_raw_ref(), rr);
|
||||||
@@ -676,8 +689,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_ext)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
||||||
EXPECT_NO_THROW(boost::get<msgpack::type::ext_ref>(val2));
|
EXPECT_NO_THROW(boost::get<msgpack::type::ext_ref>(val2));
|
||||||
EXPECT_TRUE(val2.is_ext_ref());
|
EXPECT_TRUE(val2.is_ext_ref());
|
||||||
@@ -726,8 +740,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_array)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
||||||
EXPECT_TRUE(val2.is_vector());
|
EXPECT_TRUE(val2.is_vector());
|
||||||
EXPECT_EQ(val2.as_vector(), v);
|
EXPECT_EQ(val2.as_vector(), v);
|
||||||
@@ -779,8 +794,9 @@ TEST(MSGPACK_BOOST, pack_convert_variant_ref_map)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
msgpack::type::variant_ref val2 = oh.get().as<msgpack::type::variant_ref>();
|
||||||
EXPECT_TRUE(val2.is_multimap());
|
EXPECT_TRUE(val2.is_multimap());
|
||||||
EXPECT_EQ(val2.as_multimap(), v);
|
EXPECT_EQ(val2.as_multimap(), v);
|
||||||
|
@@ -15,7 +15,8 @@ TEST(carray, pack_unpack_int)
|
|||||||
int v1[] = { 0, 1 };
|
int v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
int v2[2];
|
int v2[2];
|
||||||
@@ -44,7 +45,8 @@ TEST(carray, pack_unpack_const_int)
|
|||||||
const int v1[] = { 0, 1 };
|
const int v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
int v2[2];
|
int v2[2];
|
||||||
@@ -73,7 +75,8 @@ TEST(carray, pack_unpack_string)
|
|||||||
std::string v1[] = { "ABC", "DEFG" };
|
std::string v1[] = { "ABC", "DEFG" };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
std::string v2[2];
|
std::string v2[2];
|
||||||
@@ -102,7 +105,8 @@ TEST(carray, pack_unpack_char)
|
|||||||
char v1[] = { 0, 1 };
|
char v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, msgpack::type::make_array_ref(v1));
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
char v2[2];
|
char v2[2];
|
||||||
@@ -118,7 +122,8 @@ TEST(carray, pack_unpack_char_as_str)
|
|||||||
char v1[2] = { 1, '\0' };
|
char v1[2] = { 1, '\0' };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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().type, msgpack::type::STR);
|
||||||
EXPECT_EQ(oh.get().via.str.size, static_cast<size_t>(1));
|
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 };
|
unsigned char v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, msgpack::type::make_array_ref(v1));
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
unsigned char v2[2];
|
unsigned char v2[2];
|
||||||
@@ -180,7 +186,8 @@ TEST(carray, pack_unpack_unsigned_char_as_bin)
|
|||||||
unsigned char v1[] = { 0, 1 };
|
unsigned char v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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().type, msgpack::type::BIN);
|
||||||
EXPECT_EQ(oh.get().via.bin.size, static_cast<size_t>(2));
|
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 };
|
signed char v1[] = { 0, 1 };
|
||||||
|
|
||||||
msgpack::pack(ss, v1);
|
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);
|
EXPECT_EQ(oh.get().type, msgpack::type::ARRAY);
|
||||||
|
|
||||||
signed char v2[2];
|
signed char v2[2];
|
||||||
|
@@ -1368,3 +1368,45 @@ TEST(MSGPACKC, vref_buffer_overflow)
|
|||||||
EXPECT_FALSE(msgpack_vrefbuffer_init(&vbuf, ref_size, chunk_size));
|
EXPECT_FALSE(msgpack_vrefbuffer_init(&vbuf, ref_size, chunk_size));
|
||||||
EXPECT_EQ(-1, msgpack_vrefbuffer_migrate(&vbuf, &to));
|
EXPECT_EQ(-1, msgpack_vrefbuffer_migrate(&vbuf, &to));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(MSGPACKC, object_print_buffer_overflow) {
|
||||||
|
msgpack_object obj;
|
||||||
|
obj.type = MSGPACK_OBJECT_NIL;
|
||||||
|
char buffer[4];
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 1, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 2, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 3, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 4, obj);
|
||||||
|
EXPECT_EQ(3, ret);
|
||||||
|
EXPECT_STREQ("nil", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MSGPACKC, object_bin_print_buffer_overflow) {
|
||||||
|
msgpack_object obj;
|
||||||
|
obj.type = MSGPACK_OBJECT_BIN;
|
||||||
|
obj.via.bin.ptr = "test";
|
||||||
|
obj.via.bin.size = 4;
|
||||||
|
char buffer[7];
|
||||||
|
|
||||||
|
int ret;
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 1, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 2, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 3, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 4, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 5, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 6, obj);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
ret = msgpack_object_print_buffer(buffer, 7, obj);
|
||||||
|
EXPECT_EQ(6, ret);
|
||||||
|
EXPECT_STREQ("\"test\"", buffer);
|
||||||
|
}
|
||||||
|
@@ -183,7 +183,7 @@ TEST(MSGPACK_CPP11, simple_buffer_array_char)
|
|||||||
for (unsigned int k = 0; k < kLoop; k++) {
|
for (unsigned int k = 0; k < kLoop; k++) {
|
||||||
array<char, kElements> val1;
|
array<char, kElements> val1;
|
||||||
for (unsigned int i = 0; i < kElements; i++)
|
for (unsigned int i = 0; i < kElements; i++)
|
||||||
val1[i] = rand();
|
val1[i] = static_cast<char>(rand());
|
||||||
msgpack::sbuffer sbuf;
|
msgpack::sbuffer sbuf;
|
||||||
msgpack::pack(sbuf, val1);
|
msgpack::pack(sbuf, val1);
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
@@ -214,7 +214,7 @@ TEST(MSGPACK_CPP11, simple_buffer_array_unsigned_char)
|
|||||||
for (unsigned int k = 0; k < kLoop; k++) {
|
for (unsigned int k = 0; k < kLoop; k++) {
|
||||||
array<unsigned char, kElements> val1;
|
array<unsigned char, kElements> val1;
|
||||||
for (unsigned int i = 0; i < kElements; i++)
|
for (unsigned int i = 0; i < kElements; i++)
|
||||||
val1[i] = rand();
|
val1[i] = static_cast<unsigned char>(rand());
|
||||||
msgpack::sbuffer sbuf;
|
msgpack::sbuffer sbuf;
|
||||||
msgpack::pack(sbuf, val1);
|
msgpack::pack(sbuf, val1);
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
@@ -1055,10 +1055,11 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_zero)
|
|||||||
timespec val1{ 0, 0 };
|
timespec val1{ 0, 0 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xd6));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xd6));
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
@@ -1080,10 +1081,11 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_32bit_sec)
|
|||||||
timespec val1{ 0xffffffffUL, 0 };
|
timespec val1{ 0xffffffffUL, 0 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xd6));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xd6));
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
@@ -1105,9 +1107,10 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_max_nano)
|
|||||||
timespec val1{ 0, 999999999 };
|
timespec val1{ 0, 999999999 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xd7));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xd7));
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
@@ -1130,10 +1133,11 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_34bit_sec_max_nano)
|
|||||||
timespec val1{ static_cast<decltype(std::declval<timespec>().tv_sec)>(0x3ffffffffULL), 999999999 };
|
timespec val1{ static_cast<decltype(std::declval<timespec>().tv_sec)>(0x3ffffffffULL), 999999999 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xd7));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xd7));
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
@@ -1157,10 +1161,11 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_35bit_sec_max_nano)
|
|||||||
timespec val1{ static_cast<decltype(std::declval<timespec>().tv_sec)>(0x7ffffffffULL), 999999999 };
|
timespec val1{ static_cast<decltype(std::declval<timespec>().tv_sec)>(0x7ffffffffULL), 999999999 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xc7));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xc7));
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
@@ -1183,10 +1188,11 @@ TEST(MSGPACK_TIMESPEC, timespec_pack_convert_64bit_sec_max_nano)
|
|||||||
timespec val1{ std::numeric_limits<decltype(std::declval<timespec>().tv_sec)>::max(), 999999999 };
|
timespec val1{ std::numeric_limits<decltype(std::declval<timespec>().tv_sec)>::max(), 999999999 };
|
||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
EXPECT_EQ(ss.str().data()[0], static_cast<char>(0xc7));
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str.data()[0], static_cast<char>(0xc7));
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
timespec val2 = oh.get().as<timespec>();
|
timespec val2 = oh.get().as<timespec>();
|
||||||
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
EXPECT_EQ(val1.tv_sec, val2.tv_sec);
|
||||||
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
EXPECT_EQ(val1.tv_nsec, val2.tv_nsec);
|
||||||
|
@@ -27,8 +27,9 @@ TEST(MSGPACK_CPP17, optional_pack_convert_nil)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::optional<int> val1;
|
std::optional<int> val1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::optional<int> val2 = oh.get().as<std::optional<int> >();
|
std::optional<int> val2 = oh.get().as<std::optional<int> >();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -38,8 +39,9 @@ TEST(MSGPACK_CPP17, optional_pack_convert_int)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::optional<int> val1 = 1;
|
std::optional<int> val1 = 1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::optional<int> val2 = oh.get().as<std::optional<int> >();
|
std::optional<int> val2 = oh.get().as<std::optional<int> >();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -55,8 +57,9 @@ TEST(MSGPACK_CPP17, optional_pack_convert_vector)
|
|||||||
v.push_back(3);
|
v.push_back(3);
|
||||||
val1 = v;
|
val1 = v;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
ovi_t val2 = oh.get().as<ovi_t>();
|
ovi_t val2 = oh.get().as<ovi_t>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -70,8 +73,9 @@ TEST(MSGPACK_CPP17, optional_pack_convert_vector_optional)
|
|||||||
val1[0] = 1;
|
val1[0] = 1;
|
||||||
val1[2] = 3;
|
val1[2] = 3;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
voi_t val2 = oh.get().as<voi_t>();
|
voi_t val2 = oh.get().as<voi_t>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -177,8 +181,9 @@ TEST(MSGPACK_CPP17, optional_pack_convert_no_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::optional<no_def_con> val1 = no_def_con(1);
|
std::optional<no_def_con> val1 = no_def_con(1);
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::optional<no_def_con> val2 = oh.get().as<std::optional<no_def_con>>();
|
std::optional<no_def_con> val2 = oh.get().as<std::optional<no_def_con>>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -195,8 +200,9 @@ TEST(MSGPACK_CPP17, string_view_pack_convert)
|
|||||||
|
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
std::string_view val2 = oh.get().as<std::string_view>();
|
std::string_view val2 = oh.get().as<std::string_view>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -230,7 +236,8 @@ TEST(MSGPACK_CPP17, byte_pack_convert)
|
|||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
std::string const& str = ss.str();
|
||||||
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
std::byte val2 = oh.get().as<std::byte>();
|
std::byte val2 = oh.get().as<std::byte>();
|
||||||
EXPECT_EQ(val1, val2);
|
EXPECT_EQ(val1, val2);
|
||||||
}
|
}
|
||||||
@@ -263,11 +270,13 @@ TEST(MSGPACK_CPP17, vector_byte_pack_convert)
|
|||||||
|
|
||||||
char packed[] = { char(0xc4), char(0x05), char(0x01), char(0x02), char(0x7f), char(0x80), char(0xff) };
|
char packed[] = { char(0xc4), char(0x05), char(0x01), char(0x02), char(0x7f), char(0x80), char(0xff) };
|
||||||
for (size_t i = 0; i != sizeof(packed); ++i) {
|
for (size_t i = 0; i != sizeof(packed); ++i) {
|
||||||
EXPECT_EQ(ss.str()[i], packed[i]);
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str[i], packed[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
std::string const& str = ss.str();
|
||||||
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
std::vector<std::byte> val2 = oh.get().as<std::vector<std::byte>>();
|
std::vector<std::byte> val2 = oh.get().as<std::vector<std::byte>>();
|
||||||
EXPECT_EQ(val1, val2);
|
EXPECT_EQ(val1, val2);
|
||||||
}
|
}
|
||||||
@@ -308,11 +317,13 @@ TEST(MSGPACK_CPP17, carray_byte_pack_convert)
|
|||||||
|
|
||||||
char packed[] = { char(0xc4), char(0x05), char(0x01), char(0x02), char(0x7f), char(0x80), char(0xff) };
|
char packed[] = { char(0xc4), char(0x05), char(0x01), char(0x02), char(0x7f), char(0x80), char(0xff) };
|
||||||
for (size_t i = 0; i != sizeof(packed); ++i) {
|
for (size_t i = 0; i != sizeof(packed); ++i) {
|
||||||
EXPECT_EQ(ss.str()[i], packed[i]);
|
std::string const& str = ss.str();
|
||||||
|
EXPECT_EQ(str[i], packed[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack::object_handle oh;
|
msgpack::object_handle oh;
|
||||||
msgpack::unpack(oh, ss.str().data(), ss.str().size());
|
std::string const& str = ss.str();
|
||||||
|
msgpack::unpack(oh, str.data(), str.size());
|
||||||
std::byte val2[sizeof(val1)];
|
std::byte val2[sizeof(val1)];
|
||||||
oh.get().convert(val2);
|
oh.get().convert(val2);
|
||||||
for (size_t i = 0; i != sizeof(val1); ++i) {
|
for (size_t i = 0; i != sizeof(val1); ++i) {
|
||||||
|
24
test/raw.cpp
24
test/raw.cpp
@@ -29,7 +29,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack)
|
|||||||
EXPECT_EQ(packed_str[4], 'C');
|
EXPECT_EQ(packed_str[4], 'C');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_l)
|
|||||||
EXPECT_EQ(packed_str[1], static_cast<char>(0x00u));
|
EXPECT_EQ(packed_str[1], static_cast<char>(0x00u));
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_8_h)
|
|||||||
EXPECT_EQ(packed_str[2], 'A');
|
EXPECT_EQ(packed_str[2], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_l)
|
|||||||
EXPECT_EQ(packed_str[3], 'A');
|
EXPECT_EQ(packed_str[3], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_16_h)
|
|||||||
EXPECT_EQ(packed_str[3], 'A');
|
EXPECT_EQ(packed_str[3], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ TEST(MSGPACK_RAW_REF, pack_unpack_32_l)
|
|||||||
EXPECT_EQ(packed_str[5], 'A');
|
EXPECT_EQ(packed_str[5], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
msgpack::type::raw_ref rr2 = oh.get().as<msgpack::type::raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack)
|
|||||||
EXPECT_EQ(packed_str[3], 'C');
|
EXPECT_EQ(packed_str[3], 'C');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_l)
|
|||||||
EXPECT_EQ(packed_str[0], static_cast<char>(0xa0u));
|
EXPECT_EQ(packed_str[0], static_cast<char>(0xa0u));
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_fix_h)
|
|||||||
EXPECT_EQ(packed_str[1], 'A');
|
EXPECT_EQ(packed_str[1], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_l)
|
|||||||
EXPECT_EQ(packed_str[3], 'A');
|
EXPECT_EQ(packed_str[3], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_16_h)
|
|||||||
EXPECT_EQ(packed_str[3], 'A');
|
EXPECT_EQ(packed_str[3], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ TEST(MSGPACK_V4RAW_REF, pack_unpack_32_l)
|
|||||||
EXPECT_EQ(packed_str[5], 'A');
|
EXPECT_EQ(packed_str[5], 'A');
|
||||||
|
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(packed_str.data(), packed_str.size());
|
||||||
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
msgpack::type::v4raw_ref rr2 = oh.get().as<msgpack::type::v4raw_ref>();
|
||||||
EXPECT_TRUE(rr1 == rr2);
|
EXPECT_TRUE(rr1 == rr2);
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,8 @@ TEST(MSGPACK_REFERENCE_WRAPPER, pack_convert)
|
|||||||
std::reference_wrapper<int> val1(i1);
|
std::reference_wrapper<int> val1(i1);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
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());
|
||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
std::reference_wrapper<int> val2(i2);
|
std::reference_wrapper<int> val2(i2);
|
||||||
oh.get().convert(val2);
|
oh.get().convert(val2);
|
||||||
@@ -33,7 +34,8 @@ TEST(MSGPACK_REFERENCE_WRAPPER, pack_convert_const)
|
|||||||
std::reference_wrapper<const int> val1(i1);
|
std::reference_wrapper<const int> val1(i1);
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
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());
|
||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
std::reference_wrapper<int> val2(i2);
|
std::reference_wrapper<int> val2(i2);
|
||||||
oh.get().convert(val2);
|
oh.get().convert(val2);
|
||||||
@@ -46,7 +48,8 @@ TEST(MSGPACK_REFERENCE_WRAPPER, pack_vector)
|
|||||||
std::vector<std::reference_wrapper<int>> val1{i1};
|
std::vector<std::reference_wrapper<int>> val1{i1};
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
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());
|
||||||
std::vector<int> val2 = oh.get().as<std::vector<int>>();
|
std::vector<int> val2 = oh.get().as<std::vector<int>>();
|
||||||
EXPECT_EQ(val2.size(), static_cast<size_t>(1));
|
EXPECT_EQ(val2.size(), static_cast<size_t>(1));
|
||||||
EXPECT_EQ(val1[0], val2[0]);
|
EXPECT_EQ(val1[0], val2[0]);
|
||||||
|
@@ -20,8 +20,9 @@ TEST(SHARED_PTR, pack_convert_nil)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::shared_ptr<int> val1;
|
std::shared_ptr<int> val1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::shared_ptr<int> val2 = oh.get().as<std::shared_ptr<int>>();
|
std::shared_ptr<int> val2 = oh.get().as<std::shared_ptr<int>>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -31,8 +32,9 @@ TEST(SHARED_PTR, pack_convert_int)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::shared_ptr<int> val1(new int(1));
|
std::shared_ptr<int> val1(new int(1));
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::shared_ptr<int> val2 = oh.get().as<std::shared_ptr<int>>();
|
std::shared_ptr<int> val2 = oh.get().as<std::shared_ptr<int>>();
|
||||||
EXPECT_TRUE(*val1 == *val2);
|
EXPECT_TRUE(*val1 == *val2);
|
||||||
}
|
}
|
||||||
@@ -119,8 +121,9 @@ TEST(SHARED_PTR, pack_convert_nil_no_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::shared_ptr<no_def_con> val1(new no_def_con(1));
|
std::shared_ptr<no_def_con> val1(new no_def_con(1));
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::shared_ptr<no_def_con> val2 = oh.get().as<std::shared_ptr<no_def_con>>();
|
std::shared_ptr<no_def_con> val2 = oh.get().as<std::shared_ptr<no_def_con>>();
|
||||||
EXPECT_TRUE(*val1 == *val2);
|
EXPECT_TRUE(*val1 == *val2);
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,8 @@ TEST(size_equal_only, array)
|
|||||||
msgpack::type::size_equal_only<int[3]> seo(buf);
|
msgpack::type::size_equal_only<int[3]> seo(buf);
|
||||||
|
|
||||||
msgpack::pack(ss, seo);
|
msgpack::pack(ss, seo);
|
||||||
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());
|
||||||
|
|
||||||
int ret_buf1[3];
|
int ret_buf1[3];
|
||||||
oh.get().convert(ret_buf1);
|
oh.get().convert(ret_buf1);
|
||||||
@@ -58,7 +59,8 @@ TEST(size_equal_only, vector)
|
|||||||
msgpack::type::size_equal_only<std::vector<int> > seo(buf);
|
msgpack::type::size_equal_only<std::vector<int> > seo(buf);
|
||||||
|
|
||||||
msgpack::pack(ss, seo);
|
msgpack::pack(ss, seo);
|
||||||
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());
|
||||||
|
|
||||||
std::vector<int> ret_buf1;
|
std::vector<int> ret_buf1;
|
||||||
oh.get().convert(ret_buf1);
|
oh.get().convert(ret_buf1);
|
||||||
@@ -91,7 +93,8 @@ TEST(size_equal_only, msgpack_tuple)
|
|||||||
msgpack::type::size_equal_only<msgpack::type::tuple<int, bool, std::string> > seo(buf);
|
msgpack::type::size_equal_only<msgpack::type::tuple<int, bool, std::string> > seo(buf);
|
||||||
|
|
||||||
msgpack::pack(ss, seo);
|
msgpack::pack(ss, seo);
|
||||||
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());
|
||||||
|
|
||||||
msgpack::type::tuple<int, bool, std::string> ret_buf1;
|
msgpack::type::tuple<int, bool, std::string> ret_buf1;
|
||||||
oh.get().convert(ret_buf1);
|
oh.get().convert(ret_buf1);
|
||||||
@@ -148,7 +151,8 @@ TEST(size_equal_only, tuple)
|
|||||||
auto seo = msgpack::type::make_size_equal_only(buf);
|
auto seo = msgpack::type::make_size_equal_only(buf);
|
||||||
|
|
||||||
msgpack::pack(ss, seo);
|
msgpack::pack(ss, seo);
|
||||||
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());
|
||||||
|
|
||||||
std::tuple<int, bool, std::string> ret_buf1;
|
std::tuple<int, bool, std::string> ret_buf1;
|
||||||
oh.get().convert(ret_buf1);
|
oh.get().convert(ret_buf1);
|
||||||
@@ -210,7 +214,8 @@ TEST(size_equal_only, custom_class)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
foo1 f1(42, true);
|
foo1 f1(42, true);
|
||||||
msgpack::pack(ss, f1);
|
msgpack::pack(ss, f1);
|
||||||
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());
|
||||||
|
|
||||||
foo2 f2(123, false, "ABC");
|
foo2 f2(123, false, "ABC");
|
||||||
try {
|
try {
|
||||||
|
@@ -20,8 +20,9 @@ TEST(UNIQUE_PTR, pack_convert_nil)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::unique_ptr<int> val1;
|
std::unique_ptr<int> val1;
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::unique_ptr<int> val2 = oh.get().as<std::unique_ptr<int>>();
|
std::unique_ptr<int> val2 = oh.get().as<std::unique_ptr<int>>();
|
||||||
EXPECT_TRUE(val1 == val2);
|
EXPECT_TRUE(val1 == val2);
|
||||||
}
|
}
|
||||||
@@ -31,8 +32,9 @@ TEST(UNIQUE_PTR, pack_convert_int)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::unique_ptr<int> val1(new int(1));
|
std::unique_ptr<int> val1(new int(1));
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::unique_ptr<int> val2 = oh.get().as<std::unique_ptr<int>>();
|
std::unique_ptr<int> val2 = oh.get().as<std::unique_ptr<int>>();
|
||||||
EXPECT_TRUE(*val1 == *val2);
|
EXPECT_TRUE(*val1 == *val2);
|
||||||
}
|
}
|
||||||
@@ -119,8 +121,9 @@ TEST(UNIQUE_PTR, pack_convert_nil_no_def_con)
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
std::unique_ptr<no_def_con> val1(new no_def_con(1));
|
std::unique_ptr<no_def_con> val1(new no_def_con(1));
|
||||||
msgpack::pack(ss, val1);
|
msgpack::pack(ss, val1);
|
||||||
|
std::string const& str = ss.str();
|
||||||
msgpack::object_handle oh =
|
msgpack::object_handle oh =
|
||||||
msgpack::unpack(ss.str().data(), ss.str().size());
|
msgpack::unpack(str.data(), str.size());
|
||||||
std::unique_ptr<no_def_con> val2 = oh.get().as<std::unique_ptr<no_def_con>>();
|
std::unique_ptr<no_def_con> val2 = oh.get().as<std::unique_ptr<no_def_con>>();
|
||||||
EXPECT_TRUE(*val1 == *val2);
|
EXPECT_TRUE(*val1 == *val2);
|
||||||
}
|
}
|
||||||
|
@@ -98,7 +98,8 @@ TEST(visitor, json_like)
|
|||||||
std::string json_like;
|
std::string json_like;
|
||||||
json_like_visitor v(json_like);
|
json_like_visitor v(json_like);
|
||||||
std::size_t off = 0;
|
std::size_t off = 0;
|
||||||
bool ret = msgpack::parse(ss.str().data(), ss.str().size(), off, v);
|
std::string const& str = ss.str();
|
||||||
|
bool ret = msgpack::parse(str.data(), str.size(), off, v);
|
||||||
EXPECT_TRUE(ret);
|
EXPECT_TRUE(ret);
|
||||||
EXPECT_EQ("{\"key\":[42,null,true]}", json_like);
|
EXPECT_EQ("{\"key\":[42,null,true]}", json_like);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user