summaryrefslogtreecommitdiff
path: root/c/test.cpp
blob: b42d931b98bcb02d957d745784bc6d13f0154d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
}