Add a flatten anonymous test for flexbuffers

This commit is contained in:
Patrick Urbanke
2023-11-15 21:01:37 +01:00
parent 23eaad1629
commit d7e9cc7496
2 changed files with 35 additions and 0 deletions
@@ -0,0 +1,33 @@
#include <cassert>
#include <iostream>
#include <rfl.hpp>
#include <rfl/flexbuf.hpp>
#include <string>
#include <vector>
#include "write_and_read.hpp"
void test_flatten_anonymous() {
std::cout << "test_flatten_anonymous" << std::endl;
struct Person {
std::string first_name;
rfl::Box<std::string> last_name;
int age;
};
struct Employee {
rfl::Flatten<Person> person;
rfl::Box<std::string> employer;
float salary;
};
const auto employee = Employee{
.person = Person{.first_name = "Homer",
.last_name = rfl::make_box<std::string>("Simpson"),
.age = 45},
.employer = rfl::make_box<std::string>("Mr. Burns"),
.salary = 60000.0};
write_and_read(employee);
}
+2
View File
@@ -7,6 +7,7 @@
#include "test_custom_constructor.hpp"
#include "test_deque.hpp"
#include "test_field_variant.hpp"
#include "test_flatten_anonymous.hpp"
#include "test_forward_list.hpp"
#include "test_list.hpp"
#include "test_literal.hpp"
@@ -36,6 +37,7 @@ int main() {
test_monster_example1();
test_monster_example2();
test_anonymous_fields();
test_flatten_anonymous();
test_optional_fields();
test_unique_ptr();
test_unique_ptr2();