mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 18:29:53 +00:00
cpp: adds fixed length serialization for integers
This commit is contained in:
parent
59ba8dec4e
commit
fe2a0f5089
8 changed files with 223 additions and 2 deletions
24
cpp/test/fixint.cc
Normal file
24
cpp/test/fixint.cc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <msgpack.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
template <typename T>
|
||||
void check_size(size_t size) {
|
||||
T v(0);
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, v);
|
||||
EXPECT_EQ(size, sbuf.size());
|
||||
}
|
||||
|
||||
TEST(fixint, size)
|
||||
{
|
||||
check_size<msgpack::type::fix_int8>(2);
|
||||
check_size<msgpack::type::fix_int16>(3);
|
||||
check_size<msgpack::type::fix_int32>(5);
|
||||
check_size<msgpack::type::fix_int64>(9);
|
||||
|
||||
check_size<msgpack::type::fix_uint8>(2);
|
||||
check_size<msgpack::type::fix_uint16>(3);
|
||||
check_size<msgpack::type::fix_uint32>(5);
|
||||
check_size<msgpack::type::fix_uint64>(9);
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue