mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 02:09:59 +00:00
add c/test.cpp cpp/test.cpp
This commit is contained in:
parent
1ba330c473
commit
d3f9ab7dec
4 changed files with 57 additions and 190 deletions
28
c/test.cpp
Normal file
28
c/test.cpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#include "msgpack.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(MSGPACKC, simple_buffer)
|
||||
{
|
||||
msgpack_sbuffer sbuf;
|
||||
msgpack_sbuffer_init(&sbuf);
|
||||
|
||||
msgpack_packer pk;
|
||||
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_int(pk, 1);
|
||||
|
||||
msgpack_zone z;
|
||||
msgpack_zone_init(&z, 2048);
|
||||
|
||||
msgpack_object obj;
|
||||
|
||||
msgpack_unpack_return ret =
|
||||
msgpack_unpack(sbuf.data, sbuf.size, NULL, &z, &obj);
|
||||
|
||||
EXPECT_EQ(ret, MSGPACK_UNPACK_SUCCESS);
|
||||
|
||||
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, obj.type);
|
||||
EXPECT_EQ(1, obj.via.u64);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue