Compare commits

..

21 Commits

Author SHA1 Message Date
Takatoshi Kondo
306d59d52f Merge pull request #1152 from redboltz/update_codecov
Updated codecov.
2025-02-21 22:39:02 +09:00
Takatoshi Kondo
0299d94105 Fixed compile time constant issue. 2025-02-21 22:22:01 +09:00
Takatoshi Kondo
51528a4389 Updated codecov. 2025-02-21 22:15:53 +09:00
Takatoshi Kondo
445880108a Merge pull request #1138 from redboltz/update_to_610c
Updated the version to 6.1.0 (C)
2024-08-17 18:28:44 +09:00
Takatoshi Kondo
b5af8ae8bc Updated the version to 6.1.0 (C) 2024-08-17 14:49:29 +09:00
Takatoshi Kondo
03551d31fd Merge pull request #1137 from redboltz/Athishpranav2003-msgpack-object-kv
Athishpranav2003 msgpack object kv
2024-08-17 14:34:17 +09:00
Takatoshi Kondo
6f24d240e1 Supported all msgpack object types.
Fixed cmake warning.
2024-08-17 13:40:58 +09:00
Athish Pranav D
985184b647 Added tests for the Init functionality
Signed-off-by: Athish Pranav D <athishanna@gmail.com>
2024-08-17 08:51:23 +05:30
Athish Pranav D
96493f581d Nit
Signed-off-by: Athish Pranav D <athishanna@gmail.com>
2024-08-13 13:31:24 +05:30
Athish Pranav D
c1cb968c04 Add msgpack obj init for complex types
Signed-off-by: Athish Pranav D <athishanna@gmail.com>
2024-08-13 13:27:17 +05:30
Takatoshi Kondo
eba6304a3a Merge pull request #1129 from redboltz/update_c_602
Updated the version to 6.0.2 (C)
2024-06-24 15:56:53 +09:00
Takatoshi Kondo
ef0927a6f0 Updated the version to 6.0.2 (C) 2024-06-24 15:30:56 +09:00
Takatoshi Kondo
bf2504e7bb Merge pull request #1125 from otegami/fix-ignored-includedir
Fix header file installation to respect `CMAKE_INSTALL_INCLUDEDIR`
2024-06-24 15:28:45 +09:00
otegami
724d1aad39 Fix header file installation paths to respect CMAKE_INSTALL_INCLUDEDIR
Previously, header files were installed uniformly under the include directory, ignoring the specified paths.
This change ensures header files are installed in the appropriate directories under `CMAKE_INSTALL_INCLUDEDIR`.
2024-06-12 20:22:02 +08:00
Takatoshi Kondo
a5c8a2c845 Merge pull request #1121 from otegami/support-absolute-path-for-pkg-config
Support absolute path for CMAKE_INSTALL_*DIR
2024-05-14 16:01:23 +09:00
otegami
4e027b72de Support absolute path for CMAKE_INSTALL_*DIR
Issue

When `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR` are set to absolute paths, the `msgpack-c.pc` file generated by CMake improperly configures `libdir` and `includedir`. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.

How to reproduce

Build and install `msgpack-c`.

```console
% cmake -S . -B ../msgpack-c.build -DCMAKE_INSTALL_LIBDIR=/tmp/local/lib -DCMAKE_INSTALL_INCLUDEDIR=/tmp/local/include
% cmake --build ../msgpack-c.build
% sudo cmake --install ../msgpack-c.build
```

Compile `example/simple_c.c` using installed msgpack-c. The following error happens because the linker cannot find paths provided by pkg-config.

```console
% export PKG_CONFIG_PATH=/tmp/local/lib/pkgconfig:$PKG_CONFIG_PATH
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
/usr/bin/ld: cannot find -lmsgpack-c: No such file or directory
collect2: error: ld returned 1 exit status
```

Expected

Successfully compile `example/simple_c.c` using installed msgpack-c. We can execute `simple_c` like the following.

```console
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
% ./simple_c
93 01 c3 a7 65 78 61 6d 70 6c 65
[1, true, "example"]
```

Explain the problem in detail

The generated `msgpack-c.pc` file does not handle absolute paths correctly. Here is the result of the incorrect configuration in `How to reproduce` section. In the following `msgpack-c.pc` file, `libdir` and `includedir` are showing unrecognized paths, leading to incorrect paths.

```console
% cat /tmp/local/lib/pkgconfig/msgpack-c.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=${prefix}//tmp/local/lib <- Here the path is wrong. We expected `/tmp/local/lib`
includedir=${prefix}//tmp/local/include <- Here the path is wrong. We expected `/tmp/local/include`

Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
```

Solution

Modify the `CMakeLists.txt` file to ensure that `libdir` and `includedir` use absolute paths. This change addresses the issue by providing correct paths to the compiler and linker.
2024-05-12 21:38:35 +08:00
Takatoshi Kondo
c31fafbcd1 Merge pull request #1119 from otegami/support-relative-path-for-pkg-config
Support relative path for CMAKE_INSTALL_*DIR
2024-04-26 13:34:22 +09:00
otegami
68cc50a3de Support relative path for CMAKE_INSTALL_*DIR
When `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR` are set to relative paths, the `msgpack-c.pc` file generated by CMake improperly configures `libdir` and `includedir`. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.

Build and install `msgpack-c`.

```console
% git switch -c c_master
% cmake -S . -B ../msgpack-c.build -DCMAKE_INSTALL_PREFIX=/tmp/local -DCMAKE_INSTALL_LIBDIR=lib-relative -DCMAKE_INSTALL_INCLUDEDIR=include-relative
% cmake --build ../msgpack-c.build
% cmake --install ../msgpack-c.build/
```

Compile `example/simple_c.c` using installed msgpack-c.
The following error happens because the linker cannot find paths provided by pkg-config.

```console
% export PKG_CONFIG_PATH=/usr/local/lib-relative/pkgconfig:$PKG_CONFIG_PATH
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
/usr/bin/ld: cannot find -lmsgpack-c: No such file or directory
collect2: error: ld returned 1 exit status
```

Successly compile `example/simple_c.c` using install msgpack-c.
We can execute `simple_c.c` like the following.

```console
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
% ./simple_c
93 01 c3 a7 65 78 61 6d 70 6c 65
[1, true, "example"]
```

The generated `msgpack-c.pc` file does not handle relative paths correctly. Here is the result of the incorrect configuration in How to reproduce section.
In the following `msgpack-c.pc` file, `libdir` and `includedir` are relative to the current directory, leading to incorrect paths.

```console
cat ../msgpack-c.build/msgpack-c.pc
prefix=/tmp/local
exec_prefix=/tmp/local
libdir=lib-relative
includedir=include-relative

Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
```

Modify the `msgpack-c.pc.in` file to ensure that `libdir` and `includedir` use absolute paths by prefixing them with ${prefix}/. This change addresses the issue by providing correct paths to the compiler and linker.
2024-04-26 12:21:26 +08:00
Takatoshi Kondo
9f37918bb5 Merge pull request #1120 from redboltz/fix_osx_ci
Removed invalid ctest option `r`.
2024-04-26 13:02:40 +09:00
Takatoshi Kondo
b8b54a2fef Updated gtest install methond on macos. 2024-04-26 12:29:23 +09:00
Takatoshi Kondo
f2c1991ede Removed invalid ctest option r. 2024-04-26 12:19:06 +09:00
12 changed files with 252 additions and 36 deletions

View File

@@ -42,12 +42,14 @@ jobs:
CMAKE_LIBRARY_PATH="${BASE}/build" GTEST_ROOT="${BASE}/usr" CMAKE_PREFIX_PATH="${BASE}/usr/gcc/lib64/cmake" cmake -DMSGPACK_32BIT=OFF -DBUILD_SHARED_LIBS=ON -DMSGPACK_CHAR_SIGN=signed -DMSGPACK_BUILD_EXAMPLES=ON -DMSGPACK_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DMSGPACK_GEN_COVERAGE=ON ..
make -j4
make test
- name: Upload coverage to Codecov
working-directory: build
- name: Generate coverage
run: |
# Create lcov report
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter system-files
lcov --list coverage.info # debug info
# Uploading report to CodeCov
bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: build/coverage.info
token: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -18,6 +18,9 @@ jobs:
pattern: [0, 1, 2, 3]
steps:
- uses: actions/checkout@v1
- name: install gtest
run: |
brew install --force googletest
- name: build and test
env:
CC: clang
@@ -48,22 +51,8 @@ jobs:
export CHAR_SIGN="unsigned"
fi
# install gtest
wget https://github.com/google/googletest/archive/release-1.7.0.zip -O googletest-release-1.7.0.zip
unzip -q googletest-release-1.7.0.zip
cd googletest-release-1.7.0
$CXX -m${ARCH} src/gtest-all.cc -I. -Iinclude -c
$CXX -m${ARCH} src/gtest_main.cc -I. -Iinclude -c
ar -rv libgtest.a gtest-all.o
ar -rv libgtest_main.a gtest_main.o
mkdir -p ${BASE}/usr/include
cp -r include/gtest ${BASE}/usr/include
mkdir -p ${BASE}/usr/lib
mv *.a ${BASE}/usr/lib
cd ..
# build and test
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g -fsanitize=undefined -fno-sanitize-recover=all" CXXFLAGS="-Werror -g -ggdb3 -fsanitize=undefined -fno-sanitize-recover=all" ${ACTION}
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" CFLAGS="-Werror -g -fsanitize=undefined -fno-sanitize-recover=all" CXXFLAGS="-Werror -g -ggdb3 -fsanitize=undefined -fno-sanitize-recover=all" ${ACTION}
linux:
runs-on: ubuntu-latest

View File

@@ -1,3 +1,13 @@
# 2024-08-17 version 6.1.0
* Add object initializer functions (#1137)
* Fix cmake warnings (#1133, #1137)
# 2024-06-24 version 6.0.2
* Fix header file installation to respect `CMAKE_INSTALL_INCLUDEDIR` (#1125)
* Support absolute path for `CMAKE_INSTALL_*DIR` (#1121)
* Removed invalid ctest option. (#1120)
* Support relative path for `CMAKE_INSTALL_*DIR{ (#1119)
# 2024-04-02 version 6.0.1
* Improve CI environment (#1061, #1091, #1109)
* Improve build system (#1060, #1069, #1108)

View File

@@ -8,6 +8,11 @@ else()
ENDIF ()
endif()
IF ((CMAKE_VERSION VERSION_GREATER 3.27) OR
(CMAKE_VERSION VERSION_EQUAL 3.27))
CMAKE_POLICY(SET CMP0145 OLD)
ENDIF ()
OPTION (MSGPACK_BUILD_TESTS "Build msgpack tests." OFF)
OPTION (MSGPACK_GEN_COVERAGE "Enable running gcov to get a test coverage report." OFF)
@@ -30,8 +35,16 @@ LIST (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
include(GNUInstallDirs)
SET (prefix ${CMAKE_INSTALL_PREFIX})
SET (exec_prefix ${CMAKE_INSTALL_PREFIX})
IF (IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
SET (libdir ${CMAKE_INSTALL_LIBDIR})
ELSE ()
SET (libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
ENDIF ()
IF (IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
SET (includedir ${CMAKE_INSTALL_INCLUDEDIR})
ELSE ()
SET (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
ENDIF ()
OPTION (MSGPACK_32BIT "32bit compile" OFF)
@@ -263,12 +276,14 @@ INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} EXPORT msgpack-c-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
FOREACH (file ${msgpack-c_common_HEADERS})
GET_FILENAME_COMPONENT (dir ${file} PATH)
INSTALL (FILES ${file} DESTINATION ${dir})
GET_FILENAME_COMPONENT(dir ${file} DIRECTORY)
STRING(REPLACE "include" "${CMAKE_INSTALL_INCLUDEDIR}" header_path ${dir})
INSTALL (FILES ${file} DESTINATION ${header_path})
ENDFOREACH ()
FOREACH (file ${msgpack-c_configured_HEADERS})
GET_FILENAME_COMPONENT (dir ${file} PATH)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION ${dir})
GET_FILENAME_COMPONENT(dir ${file} DIRECTORY)
STRING(REPLACE "include" "${CMAKE_INSTALL_INCLUDEDIR}" header_path ${dir})
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION ${header_path})
ENDFOREACH ()
IF (NOT MSVC)
INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

View File

@@ -1,8 +1,8 @@
`msgpack` for C
===================
Version 6.0.1 [![Build Status](https://github.com/msgpack/msgpack-c/workflows/CI/badge.svg?branch=c_master)](https://github.com/msgpack/msgpack-c/actions) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/c_master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/c_master)
[![codecov](https://codecov.io/gh/msgpack/msgpack-c/branch/c_master/graph/badge.svg)](https://codecov.io/gh/msgpack/msgpack-c/branch/c_master)
Version 6.1.0 [![Build Status](https://github.com/msgpack/msgpack-c/workflows/CI/badge.svg?branch=c_master)](https://github.com/msgpack/msgpack-c/actions) [![Build status](https://ci.appveyor.com/api/projects/status/8kstcgt79qj123mw/branch/c_master?svg=true)](https://ci.appveyor.com/project/redboltz/msgpack-c/branch/c_master)
[![codecov](https://codecov.io/gh/msgpack/msgpack-c/branch/c_master/graph/badge.svg)](https://app.codecov.io/gh/msgpack/msgpack-c/tree/c_master)
It's like JSON but smaller and faster.

View File

@@ -1,4 +1,4 @@
version: 6.0.1.{build}
version: 6.1.0.{build}
branches:
only:

View File

@@ -42,7 +42,7 @@ then
exit $ret
fi
ctest -VVr
ctest -VV
ret=$?
if [ $ret -ne 0 ]

View File

@@ -27,10 +27,6 @@ comment:
ignore:
- "test"
- "fuzz"
- "erb"
- "ci"
- "cmake"
- "examle"
- "external"
- "usr"
- "example"

View File

@@ -97,6 +97,39 @@ typedef struct msgpack_object_kv {
msgpack_object val;
} msgpack_object_kv;
MSGPACK_DLLEXPORT
void msgpack_object_init_nil(msgpack_object* d);
MSGPACK_DLLEXPORT
void msgpack_object_init_boolean(msgpack_object* d, bool v);
MSGPACK_DLLEXPORT
void msgpack_object_init_unsigned_integer(msgpack_object* d, uint64_t v);
MSGPACK_DLLEXPORT
void msgpack_object_init_signed_integer(msgpack_object* d, int64_t v);
MSGPACK_DLLEXPORT
void msgpack_object_init_float32(msgpack_object* d, float v);
MSGPACK_DLLEXPORT
void msgpack_object_init_float64(msgpack_object* d, double v);
MSGPACK_DLLEXPORT
void msgpack_object_init_str(msgpack_object* d, const char* data, uint32_t size);
MSGPACK_DLLEXPORT
void msgpack_object_init_bin(msgpack_object* d, const char* data, uint32_t size);
MSGPACK_DLLEXPORT
void msgpack_object_init_ext(msgpack_object* d, int8_t type, const char* data, uint32_t size);
MSGPACK_DLLEXPORT
void msgpack_object_init_array(msgpack_object* d, msgpack_object* data, uint32_t size);
MSGPACK_DLLEXPORT
void msgpack_object_init_map(msgpack_object* d, msgpack_object_kv* data, uint32_t size);
#if !defined(_KERNEL_MODE)
MSGPACK_DLLEXPORT
void msgpack_object_print(FILE* out, msgpack_object o);

View File

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

View File

@@ -125,6 +125,72 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
}
}
void msgpack_object_init_nil(msgpack_object* d) {
d->type = MSGPACK_OBJECT_NIL;
}
void msgpack_object_init_boolean(msgpack_object* d, bool v) {
d->type = MSGPACK_OBJECT_BOOLEAN;
d->via.boolean = v;
}
void msgpack_object_init_unsigned_integer(msgpack_object* d, uint64_t v) {
d->type = MSGPACK_OBJECT_POSITIVE_INTEGER;
d->via.u64 = v;
}
void msgpack_object_init_signed_integer(msgpack_object* d, int64_t v) {
if (v < 0) {
d->type = MSGPACK_OBJECT_NEGATIVE_INTEGER;
d->via.i64 = v;
}
else {
d->type = MSGPACK_OBJECT_POSITIVE_INTEGER;
d->via.u64 = v;
}
}
void msgpack_object_init_float32(msgpack_object* d, float v) {
d->type = MSGPACK_OBJECT_FLOAT32;
d->via.f64 = v;
}
void msgpack_object_init_float64(msgpack_object* d, double v) {
d->type = MSGPACK_OBJECT_FLOAT64;
d->via.f64 = v;
}
void msgpack_object_init_str(msgpack_object* d, const char* data, uint32_t size) {
d->type = MSGPACK_OBJECT_STR;
d->via.str.ptr = data;
d->via.str.size = size;
}
void msgpack_object_init_bin(msgpack_object* d, const char* data, uint32_t size) {
d->type = MSGPACK_OBJECT_BIN;
d->via.bin.ptr = data;
d->via.bin.size = size;
}
void msgpack_object_init_ext(msgpack_object* d, int8_t type, const char* data, uint32_t size) {
d->type = MSGPACK_OBJECT_EXT;
d->via.ext.type = type;
d->via.ext.ptr = data;
d->via.ext.size = size;
}
void msgpack_object_init_array(msgpack_object* d, msgpack_object* data, uint32_t size) {
d->type = MSGPACK_OBJECT_ARRAY;
d->via.array.ptr = data;
d->via.array.size = size;
}
void msgpack_object_init_map(msgpack_object* d, msgpack_object_kv* data, uint32_t size) {
d->type = MSGPACK_OBJECT_MAP;
d->via.map.ptr = data;
d->via.map.size = size;
}
#if !defined(_KERNEL_MODE)
static void msgpack_object_bin_print(FILE* out, const char *ptr, size_t size)

View File

@@ -1612,6 +1612,111 @@ TEST(MSGPACKC, object_bin_print_buffer_overflow) {
EXPECT_STREQ("\"test\"", buffer);
}
TEST(MSGPACKC, init_msgpack_obj_nil) {
msgpack_object obj;
msgpack_object_init_nil(&obj);
EXPECT_EQ(MSGPACK_OBJECT_NIL, obj.type);
}
TEST(MSGPACKC, init_msgpack_obj_boolean) {
msgpack_object obj;
msgpack_object_init_boolean(&obj, true);
EXPECT_EQ(MSGPACK_OBJECT_BOOLEAN, obj.type);
EXPECT_EQ(true, obj.via.boolean);
}
TEST(MSGPACKC, init_msgpack_obj_unsigned_integer) {
msgpack_object obj;
msgpack_object_init_unsigned_integer(&obj, 123);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, obj.type);
EXPECT_EQ(static_cast<uint64_t>(123), obj.via.u64);
}
TEST(MSGPACKC, init_msgpack_obj_signed_integer1) {
msgpack_object obj;
msgpack_object_init_signed_integer(&obj, -123);
EXPECT_EQ(MSGPACK_OBJECT_NEGATIVE_INTEGER, obj.type);
EXPECT_EQ(-123, obj.via.i64);
}
TEST(MSGPACKC, init_msgpack_obj_signed_integer2) {
msgpack_object obj;
msgpack_object_init_signed_integer(&obj, 123);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, obj.type);
EXPECT_EQ(static_cast<uint64_t>(123), obj.via.u64);
}
TEST(MSGPACKC, init_msgpack_obj_float32) {
msgpack_object obj;
float val = 1.23f;
msgpack_object_init_float32(&obj, val);
EXPECT_EQ(MSGPACK_OBJECT_FLOAT32, obj.type);
EXPECT_TRUE(fabs(obj.via.f64 - val) <= kEPS);
}
TEST(MSGPACKC, init_msgpack_obj_float64) {
msgpack_object obj;
double val = 1.23;
msgpack_object_init_float64(&obj, val);
EXPECT_EQ(MSGPACK_OBJECT_FLOAT64, obj.type);
EXPECT_TRUE(fabs(obj.via.f64 - val) <= kEPS);
}
TEST(MSGPACKC, init_msgpack_obj_string) {
msgpack_object obj;
char buffer[] = "test";
msgpack_object_init_str(&obj, buffer, (uint32_t)strlen(buffer));
EXPECT_EQ(MSGPACK_OBJECT_STR, obj.type);
EXPECT_STREQ(buffer, obj.via.str.ptr);
}
TEST(MSGPACKC, init_msgpack_obj_bin) {
msgpack_object obj;
char buffer[] = "test";
msgpack_object_init_bin(&obj, buffer, (uint32_t)strlen(buffer));
EXPECT_EQ(MSGPACK_OBJECT_BIN, obj.type);
EXPECT_STREQ(buffer, obj.via.bin.ptr);
}
TEST(MSGPACKC, init_msgpack_obj_ext) {
msgpack_object obj;
char buffer[] = "test";
msgpack_object_init_ext(&obj, 1, buffer, (uint32_t)strlen(buffer));
EXPECT_EQ(MSGPACK_OBJECT_EXT, obj.type);
EXPECT_EQ(1, obj.via.ext.type);
EXPECT_STREQ(buffer, obj.via.ext.ptr);
}
#define BUFFER_SIZE 4
TEST(MSGPACKC, init_msgpack_obj_array) {
msgpack_object obj;
char buffer[][7] = {"test_1", "test_2", "test_3", "test_4"};
msgpack_object array[BUFFER_SIZE];
for(size_t i = 0; i < BUFFER_SIZE; i++) {
msgpack_object_init_str(&array[i], buffer[i], (uint32_t)strlen(buffer[i]));
}
msgpack_object_init_array(&obj, array, BUFFER_SIZE);
EXPECT_EQ(MSGPACK_OBJECT_ARRAY, obj.type);
for(size_t i = 0; i < BUFFER_SIZE; i++) {
EXPECT_STREQ(buffer[i], obj.via.array.ptr[i].via.str.ptr);
}
}
TEST(MSGPACKC, init_msgpack_obj_map) {
msgpack_object obj;
char key_str[] = "test_key";
char value_str[] = "test_value";
msgpack_object key,value;
msgpack_object_init_str(&key, key_str, (uint32_t)strlen(key_str));
msgpack_object_init_str(&value, value_str, (uint32_t)strlen(value_str));
msgpack_object_kv map = { key, value };
msgpack_object_init_map(&obj, &map, 1);
EXPECT_EQ(MSGPACK_OBJECT_MAP, obj.type);
EXPECT_STREQ(key_str, obj.via.map.ptr->key.via.str.ptr);
EXPECT_STREQ(value_str, obj.via.map.ptr->val.via.str.ptr);
}
/* test for vrefbuffer */
#define GEN_TEST_VREFBUFFER_PREPARE(...) \
msgpack_vrefbuffer vbuf; \