Skip to content

Commit 9d2ca19

Browse files
author
pfeatherstone
committed
more unit tests
1 parent ad65a08 commit 9d2ca19

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,36 @@ BOOST_AUTO_TEST_CASE(test_serialize_custom_struct)
349349

350350
BOOST_TEST_REQUIRE(buf2.size() > 0lu);
351351
}
352+
353+
BOOST_AUTO_TEST_CASE(test_deserialize_basic_types)
354+
{
355+
std::mt19937 eng(std::random_device{}());
356+
std::vector<uint8_t> buf;
357+
358+
for (int repeat = 0 ; repeat < 100000 ; ++repeat)
359+
{
360+
const bool a = std::uniform_int_distribution<int>{0,1}(eng) == 1;
361+
// const uint8_t a = random_int<uint8_t>(eng);
362+
// const int8_t b = random_int<int8_t>(eng);
363+
// const uint16_t c = random_int<uint16_t>(eng);
364+
// const int16_t d = random_int<int16_t>(eng);
365+
// const uint32_t e = random_int<uint32_t>(eng);
366+
// const int32_t f = random_int<int32_t>(eng);
367+
// const uint64_t g = random_int<uint64_t>(eng);
368+
// const int64_t h = random_int<int64_t>(eng);
369+
// const float i = random_float<float>(eng);
370+
// const double j = random_float<double>(eng);
371+
372+
using namespace msgpackcpp;
373+
auto out = sink(buf);
374+
serialize(out, a);
375+
376+
bool aa{};
377+
auto in = source(buf);
378+
deserialize(in, aa);
379+
380+
BOOST_TEST_REQUIRE(a == aa);
381+
382+
buf.clear();
383+
}
384+
}

0 commit comments

Comments
 (0)