mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-27 21:36:19 +08:00
28 lines
732 B
C++
28 lines
732 B
C++
#include <memory>
|
|
#include <rfl.hpp>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "write_and_read.hpp"
|
|
|
|
namespace test_unique_ptr {
|
|
|
|
struct Person {
|
|
rfl::Rename<"firstName", std::string> first_name;
|
|
rfl::Rename<"lastName", std::string> last_name = "Simpson";
|
|
std::unique_ptr<std::vector<Person>> children;
|
|
};
|
|
|
|
TEST(msgpack, test_unique_ptr) {
|
|
auto children = std::make_unique<std::vector<Person>>();
|
|
children->emplace_back(Person{.first_name = "Bart"});
|
|
children->emplace_back(Person{.first_name = "Lisa"});
|
|
children->emplace_back(Person{.first_name = "Maggie"});
|
|
|
|
const auto homer =
|
|
Person{.first_name = "Homer", .children = std::move(children)};
|
|
|
|
write_and_read(homer);
|
|
}
|
|
} // namespace test_unique_ptr
|