Files
2025-10-13 18:16:14 +02:00

20 lines
575 B
C++

#ifndef WRITE_AND_READ_
#define WRITE_AND_READ_
#include <gtest/gtest.h>
#include <rfl/msgpack.hpp>
template <class... Ps>
void write_and_read(const auto& _struct) {
using T = std::remove_cvref_t<decltype(_struct)>;
const auto serialized1 = rfl::msgpack::write<Ps...>(_struct);
const auto res = rfl::msgpack::read<T, Ps...>(serialized1);
EXPECT_TRUE(res && true) << "Test failed on read. Error: "
<< res.error().what();
const auto serialized2 = rfl::msgpack::write<Ps...>(res.value());
EXPECT_EQ(serialized1, serialized2);
}
#endif