Commit 79081a84 authored by Dominik Charousset's avatar Dominik Charousset

Add test for serializing variants

parent 2c1ad297
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "caf/stream_deserializer.hpp" #include "caf/stream_deserializer.hpp"
#include "caf/stream_serializer.hpp" #include "caf/stream_serializer.hpp"
#include "caf/streambuf.hpp" #include "caf/streambuf.hpp"
#include "caf/variant.hpp"
#include "caf/detail/enum_to_string.hpp" #include "caf/detail/enum_to_string.hpp"
#include "caf/detail/get_mac_addresses.hpp" #include "caf/detail/get_mac_addresses.hpp"
...@@ -530,6 +531,17 @@ SERIALIZATION_TEST(non_empty_vector) { ...@@ -530,6 +531,17 @@ SERIALIZATION_TEST(non_empty_vector) {
CAF_CHECK_EQUAL(foo, bar); CAF_CHECK_EQUAL(foo, bar);
} }
SERIALIZATION_TEST(variant_with_tree_types) {
CAF_MESSAGE("deserializing into a non-empty vector overrides any content");
using test_variant = variant<int, double, std::string>;
test_variant x{42};
CAF_CHECK_EQUAL(x, roundtrip(x));
x = 12.34;
CAF_CHECK_EQUAL(x, roundtrip(x));
x = std::string{"foobar"};
CAF_CHECK_EQUAL(x, roundtrip(x));
}
// -- our vector<bool> serialization packs into an uint64_t. Hence, the // -- our vector<bool> serialization packs into an uint64_t. Hence, the
// critical sizes to test are 0, 1, 63, 64, and 65. // critical sizes to test are 0, 1, 63, 64, and 65.
......
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