mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-28 22:06:19 +08:00
20 lines
575 B
C++
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
|