Commit e2cf866b authored by Dominik Charousset's avatar Dominik Charousset

Fix BASP unit tests

parent bf53a25f
...@@ -129,10 +129,13 @@ struct fixture : test_coordinator_fixture<> { ...@@ -129,10 +129,13 @@ struct fixture : test_coordinator_fixture<> {
#define RECEIVE(msg_type, op_data, ...) \ #define RECEIVE(msg_type, op_data, ...) \
do { \ do { \
serializer_impl<buffer_type> source{sys, output}; \ binary_deserializer source{sys, output}; \
basp::header hdr; \ basp::header hdr; \
if (auto err = source(hdr, __VA_ARGS__)) \ if (auto err = source(hdr, __VA_ARGS__)) \
CAF_FAIL("failed to receive data: " << sys.render(err)); \ CAF_FAIL("failed to receive data: " << sys.render(err)); \
if (source.remaining() != 0) \
CAF_FAIL("unable to read entire message, " << source.remaining() \
<< " bytes left in buffer"); \
CAF_CHECK_EQUAL(hdr.type, msg_type); \ CAF_CHECK_EQUAL(hdr.type, msg_type); \
CAF_CHECK_EQUAL(hdr.operation_data, op_data); \ CAF_CHECK_EQUAL(hdr.operation_data, op_data); \
output.clear(); \ output.clear(); \
......
...@@ -36,12 +36,18 @@ CAF_TEST(serialization) { ...@@ -36,12 +36,18 @@ CAF_TEST(serialization) {
CAF_CHECK_EQUAL(sink(x), none); CAF_CHECK_EQUAL(sink(x), none);
} }
CAF_CHECK_EQUAL(buf.size(), basp::header_size); CAF_CHECK_EQUAL(buf.size(), basp::header_size);
auto buf2 = to_bytes(x);
CAF_REQUIRE_EQUAL(buf.size(), buf2.size());
CAF_CHECK(std::equal(buf.begin(), buf.end(), buf2.begin()));
basp::header y; basp::header y;
{ {
binary_deserializer source{nullptr, buf}; binary_deserializer source{nullptr, buf};
CAF_CHECK_EQUAL(source(y), none); CAF_CHECK_EQUAL(source(y), none);
} }
CAF_CHECK_EQUAL(x, y); CAF_CHECK_EQUAL(x, y);
auto z = basp::header::from_bytes(buf);
CAF_CHECK_EQUAL(x, z);
CAF_CHECK_EQUAL(y, z);
} }
CAF_TEST(to_string) { CAF_TEST(to_string) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment