mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 02:36:18 +08:00
@@ -45,6 +45,7 @@
|
||||
*.cbor
|
||||
*.json
|
||||
*.fb
|
||||
*.flexbuf
|
||||
*.msgpack
|
||||
*.toml
|
||||
*.xml
|
||||
|
||||
+6
-2
@@ -12,7 +12,7 @@ option(REFLECTCPP_YAML "Enable YAML support" OFF)
|
||||
option(REFLECTCPP_BUILD_TESTS "Build tests" OFF)
|
||||
|
||||
set(REFLECTCPP_USE_VCPKG_DEFAULT OFF)
|
||||
if (REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_YAML)
|
||||
if (REFLECTCPP_BUILD_TESTS OR REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_YAML)
|
||||
# enable vcpkg per default if require features other than JSON
|
||||
set(REFLECTCPP_USE_VCPKG_DEFAULT ON)
|
||||
endif()
|
||||
@@ -85,10 +85,14 @@ endif ()
|
||||
target_compile_options(reflectcpp PRIVATE -Wall)
|
||||
|
||||
if (REFLECTCPP_BUILD_TESTS)
|
||||
if (MSVC)
|
||||
set(REFLECT_CPP_GTEST_LIB "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
else ()
|
||||
set(REFLECT_CPP_GTEST_LIB "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libgtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif ()
|
||||
add_subdirectory(tests)
|
||||
endif ()
|
||||
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
|
||||
@@ -530,6 +530,17 @@ vcpkg is a great, but very ambitious and complex project (just like C++ is a gre
|
||||
|
||||
## Compiling and running the tests
|
||||
|
||||
reflect-cpp uses vcpkg for dependency management, including
|
||||
gtest, which is required for the tests.
|
||||
|
||||
```bash
|
||||
# bootstrap vcpkg if you haven't done so already
|
||||
git submodule update --init
|
||||
./vcpkg/bootstrap-vcpkg.sh # Linux, macOS
|
||||
./vcpkg/bootstrap-vcpkg.bat # Windows
|
||||
# You may be prompted to install additional dependencies.
|
||||
```
|
||||
|
||||
### JSON only
|
||||
|
||||
To compile the tests, do the following:
|
||||
@@ -551,12 +562,6 @@ To run the tests, do the following:
|
||||
To compile the tests with serialization formats other than JSON, do the following:
|
||||
|
||||
```bash
|
||||
# bootstrap vcpkg if you haven't done so already
|
||||
git submodule update --init
|
||||
./vcpkg/bootstrap-vcpkg.sh # Linux, macOS
|
||||
./vcpkg/bootstrap-vcpkg.bat # Windows
|
||||
# You may be prompted to install additional dependencies.
|
||||
|
||||
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build build -j 4 # gcc, clang
|
||||
cmake --build build --config Release -j 4 # MSVC
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
project(reflect-cpp-bson-tests)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "*.cpp")
|
||||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp")
|
||||
|
||||
add_executable(reflect-cpp-bson-tests ${SOURCES})
|
||||
add_executable(
|
||||
reflect-cpp-bson-tests
|
||||
${SOURCES}
|
||||
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc"
|
||||
)
|
||||
|
||||
target_include_directories(reflect-cpp-bson-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
|
||||
target_link_libraries(reflect-cpp-bson-tests PRIVATE reflectcpp)
|
||||
|
||||
target_link_libraries(
|
||||
reflect-cpp-bson-tests
|
||||
PRIVATE
|
||||
reflectcpp
|
||||
"${REFLECT_CPP_GTEST_LIB}"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_array.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -8,7 +6,7 @@
|
||||
#include <string>
|
||||
|
||||
// Make sure things still compile when
|
||||
// rfl.hpp is included after rfl/bson.hpp.
|
||||
// rfl.hpp is included after rfl/cbor.hpp.
|
||||
#include <rfl.hpp>
|
||||
|
||||
#include "write_and_read.hpp"
|
||||
@@ -21,9 +19,7 @@ struct Person {
|
||||
std::unique_ptr<std::array<Person, 3>> children = nullptr;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_array) {
|
||||
auto bart = Person{.first_name = "Bart"};
|
||||
|
||||
auto lisa = Person{.first_name = "Lisa"};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_array{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_box.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -29,9 +27,7 @@ struct DecisionTree {
|
||||
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_box) {
|
||||
auto leaf1 = DecisionTree::Leaf{.value = 3.0};
|
||||
|
||||
auto leaf2 = DecisionTree::Leaf{.value = 5.0};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_box{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class1.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -31,9 +29,7 @@ struct Person {
|
||||
PersonImpl impl;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_custom_class1) {
|
||||
const auto bart = Person("Bart");
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class1{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class3.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -56,9 +54,7 @@ struct Parser<ReaderType, WriterType, test_custom_class3::Person>
|
||||
|
||||
namespace test_custom_class3 {
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_custom_class3) {
|
||||
const auto bart = Person("Bart", "Simpson", 10);
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class3{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class4.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -57,9 +55,7 @@ struct Parser<ReaderType, WriterType, test_custom_class4::Person>
|
||||
|
||||
namespace test_custom_class4 {
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_custom_class4) {
|
||||
const auto bart = test_custom_class4::Person(
|
||||
"Bart", rfl::make_box<std::string>("Simpson"), 10);
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class4{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_default_values.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -17,9 +15,7 @@ struct Person {
|
||||
std::vector<Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_default_values) {
|
||||
const auto bart = Person{.first_name = "Bart"};
|
||||
const auto lisa = Person{.first_name = "Lisa"};
|
||||
const auto maggie = Person{.first_name = "Maggie"};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_default_values{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_deque.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::deque<Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_default_values) {
|
||||
auto children = std::make_unique<std::deque<Person>>();
|
||||
children->emplace_back(Person{.first_name = "Bart"});
|
||||
children->emplace_back(Person{.first_name = "Lisa"});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_deque{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_enum.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -18,9 +16,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_enum) {
|
||||
const auto circle = Circle{.radius = 2.0, .color = Color::green};
|
||||
|
||||
write_and_read(circle);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_enum {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_field_variant.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -28,9 +26,7 @@ using Shapes = rfl::Variant<rfl::Field<"circle", Circle>,
|
||||
rfl::Field<"rectangle", Rectangle>,
|
||||
rfl::Field<"square", rfl::Box<Square>>>;
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_field_variant) {
|
||||
const Shapes r =
|
||||
rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5});
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_field_variant{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_enum.hpp"
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_flag_enum {
|
||||
@@ -27,9 +26,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_flag_enum) {
|
||||
const auto circle =
|
||||
Circle{.radius = 2.0, .color = Color::blue | Color::orange};
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flag_enum {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_enum.hpp"
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_flag_enum_with_int {
|
||||
@@ -27,9 +26,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_flag_enum_with_int) {
|
||||
const auto circle = Circle{.radius = 2.0, .color = static_cast<Color>(10000)};
|
||||
|
||||
write_and_read(circle);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flag_enum_with_int {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_flatten.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -23,9 +21,7 @@ struct Employee {
|
||||
rfl::Field<"salary", float> salary;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_flatten) {
|
||||
const auto employee = Employee{
|
||||
.person = Person{.first_name = "Homer",
|
||||
.last_name = rfl::make_box<std::string>("Simpson"),
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flatten{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_flatten_anonymous.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -23,9 +21,7 @@ struct Employee {
|
||||
float salary;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_flatten_anonymous) {
|
||||
const auto employee = Employee{
|
||||
.person = Person{.first_name = "Homer",
|
||||
.last_name = rfl::make_box<std::string>("Simpson"),
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flatten_anonymous{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_forward_list.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::forward_list<Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_forward_list) {
|
||||
auto children = std::make_unique<std::forward_list<Person>>();
|
||||
children->emplace_front(Person{.first_name = "Maggie"});
|
||||
children->emplace_front(Person{.first_name = "Lisa"});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_forward_list{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_literal.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -20,9 +18,7 @@ struct Person {
|
||||
std::vector<Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_literal) {
|
||||
const auto bart = Person{.first_name = FirstName::make<"Bart">()};
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_literal{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_literal_map.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -14,9 +12,7 @@ namespace test_literal_map {
|
||||
|
||||
using FieldName = rfl::Literal<"firstName", "lastName">;
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_literal_map) {
|
||||
std::map<FieldName, std::unique_ptr<std::string>> homer;
|
||||
homer.insert(std::make_pair(FieldName::make<"firstName">(),
|
||||
std::make_unique<std::string>("Homer")));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_literal_map{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_map.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <rfl.hpp>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::map<std::string, Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_map) {
|
||||
auto children = std::map<std::string, Person>();
|
||||
children.insert(std::make_pair("child1", Person{.first_name = "Bart"}));
|
||||
children.insert(std::make_pair("child2", Person{.first_name = "Lisa"}));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_map{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_map_with_key_validation.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <rfl.hpp>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::map<rfl::AlphaNumeric, Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_map_with_key_validation) {
|
||||
auto children = std::make_unique<std::map<rfl::AlphaNumeric, Person>>();
|
||||
|
||||
children->insert(std::make_pair("Bart", Person{.first_name = "Bart"}));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_map_with_key_validation{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_monster_example.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -38,9 +36,7 @@ struct Monster {
|
||||
std::vector<Vec3> path;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_monster_example) {
|
||||
const auto sword = Weapon{.name = "Sword", .damage = 3};
|
||||
const auto axe = Weapon{.name = "Axe", .damage = 5};
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_monster_example{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_readme_example.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -22,9 +20,7 @@ struct Person {
|
||||
std::vector<Person> child;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_readme_example) {
|
||||
const auto bart = Person{.first_name = "Bart",
|
||||
.birthday = "1987-04-19",
|
||||
.age = 10,
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_readme_example{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_readme_example.hpp"
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_readme_example2 {
|
||||
@@ -15,9 +14,7 @@ struct Person {
|
||||
int age;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_readme_example2) {
|
||||
const auto homer =
|
||||
Person{.first_name = "Homer", .last_name = "Simpson", .age = 45};
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_readme_example2 {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_ref.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -29,9 +27,7 @@ struct DecisionTree {
|
||||
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_ref) {
|
||||
const auto leaf1 = DecisionTree::Leaf{.value = 3.0};
|
||||
|
||||
const auto leaf2 = DecisionTree::Leaf{.value = 5.0};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_ref{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_save_load.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -8,6 +6,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace test_save_load {
|
||||
|
||||
using Age = rfl::Validator<unsigned int,
|
||||
@@ -22,9 +22,7 @@ struct Person {
|
||||
std::vector<Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_save_load) {
|
||||
const auto bart = Person{.first_name = "Bart",
|
||||
.last_name = "Simpson",
|
||||
.birthday = "1987-04-19",
|
||||
@@ -59,12 +57,6 @@ void test() {
|
||||
const auto string1 = rfl::bson::write(homer1);
|
||||
const auto string2 = rfl::bson::write(homer2);
|
||||
|
||||
if (string1 != string2) {
|
||||
std::cout << "Test failed. Content was not identical." << std::endl
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl << std::endl;
|
||||
EXPECT_EQ(string1, string2);
|
||||
}
|
||||
} // namespace test_save_load
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_save_load {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_set.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::set<std::string>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_set) {
|
||||
auto children = std::make_unique<std::set<std::string>>(
|
||||
std::set<std::string>({"Bart", "Lisa", "Maggie"}));
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_set{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_size.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -19,9 +17,7 @@ struct Person {
|
||||
children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_size) {
|
||||
const auto bart = Person{
|
||||
.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"};
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_size{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_string_map.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -10,9 +8,7 @@
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_string_map {
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_string_map) {
|
||||
std::map<std::string, std::unique_ptr<std::string>> homer;
|
||||
homer.insert(
|
||||
std::make_pair("firstName", std::make_unique<std::string>("Homer")));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_string_map{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_tagged_union.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -26,11 +24,8 @@ struct Square {
|
||||
|
||||
using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>;
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_tagged_union) {
|
||||
const Shapes r = Rectangle{.height = 10, .width = 5};
|
||||
|
||||
write_and_read(r);
|
||||
}
|
||||
} // namespace test_tagged_union
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_tagged_union{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_timestamp.hpp"
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -19,9 +17,7 @@ struct Person {
|
||||
TS birthday;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_timestamp) {
|
||||
const auto result = TS::from_string("nonsense");
|
||||
|
||||
if (result) {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_timestamp{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_unique_ptr.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <rfl.hpp>
|
||||
@@ -17,9 +15,7 @@ struct Person {
|
||||
std::unique_ptr<std::vector<Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, 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"});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_unique_ptr{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_unique_ptr2.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -29,9 +27,7 @@ struct DecisionTree {
|
||||
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_unique_ptr2) {
|
||||
auto leaf1 = DecisionTree::Leaf{.value = 3.0};
|
||||
|
||||
auto leaf2 = DecisionTree::Leaf{.value = 5.0};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_unique_ptr2{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_variant.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -26,9 +24,7 @@ struct Square {
|
||||
|
||||
using Shapes = std::variant<Circle, Rectangle, std::unique_ptr<Square>>;
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(bson, test_variant) {
|
||||
const Shapes r = Rectangle{.height = 10, .width = 5};
|
||||
|
||||
write_and_read(r);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_variant{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_wstring.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -9,17 +7,15 @@
|
||||
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
struct Test {
|
||||
struct TestStruct {
|
||||
std::string theNormalString;
|
||||
std::wstring theWiderString;
|
||||
};
|
||||
|
||||
namespace test_wstring {
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
const Test test = Test{.theNormalString = "The normal string",
|
||||
.theWiderString = L"The wider string"};
|
||||
TEST(bson, test_wstring) {
|
||||
const auto test = TestStruct{.theNormalString = "The normal string",
|
||||
.theWiderString = L"The wider string"};
|
||||
|
||||
write_and_read(test);
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace test_wstring {
|
||||
void test();
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
#include "test_array.hpp"
|
||||
#include "test_box.hpp"
|
||||
#include "test_custom_class1.hpp"
|
||||
#include "test_custom_class3.hpp"
|
||||
#include "test_custom_class4.hpp"
|
||||
#include "test_default_values.hpp"
|
||||
#include "test_deque.hpp"
|
||||
#include "test_enum.hpp"
|
||||
#include "test_field_variant.hpp"
|
||||
#include "test_flag_enum.hpp"
|
||||
#include "test_flag_enum_with_int.hpp"
|
||||
#include "test_flatten.hpp"
|
||||
#include "test_flatten_anonymous.hpp"
|
||||
#include "test_forward_list.hpp"
|
||||
#include "test_literal.hpp"
|
||||
#include "test_literal_map.hpp"
|
||||
#include "test_map.hpp"
|
||||
#include "test_map_with_key_validation.hpp"
|
||||
#include "test_monster_example.hpp"
|
||||
#include "test_readme_example.hpp"
|
||||
#include "test_readme_example2.hpp"
|
||||
#include "test_ref.hpp"
|
||||
#include "test_save_load.hpp"
|
||||
#include "test_set.hpp"
|
||||
#include "test_size.hpp"
|
||||
#include "test_tagged_union.hpp"
|
||||
#include "test_timestamp.hpp"
|
||||
#include "test_unique_ptr.hpp"
|
||||
#include "test_unique_ptr2.hpp"
|
||||
#include "test_variant.hpp"
|
||||
#include "test_wstring.hpp"
|
||||
|
||||
int main() {
|
||||
test_readme_example::test();
|
||||
test_readme_example2::test();
|
||||
test_flatten::test();
|
||||
test_flatten_anonymous::test();
|
||||
test_enum::test();
|
||||
test_flag_enum::test();
|
||||
test_flag_enum_with_int::test();
|
||||
test_map::test();
|
||||
test_map_with_key_validation::test();
|
||||
test_variant::test();
|
||||
test_field_variant::test();
|
||||
test_tagged_union::test();
|
||||
test_deque::test();
|
||||
test_forward_list::test();
|
||||
test_literal_map::test();
|
||||
test_literal::test();
|
||||
test_monster_example::test();
|
||||
test_ref::test();
|
||||
test_set::test();
|
||||
test_size::test();
|
||||
test_timestamp::test();
|
||||
test_unique_ptr::test();
|
||||
test_unique_ptr2::test();
|
||||
test_array::test();
|
||||
test_box::test();
|
||||
test_custom_class1::test();
|
||||
test_custom_class3::test();
|
||||
test_custom_class4::test();
|
||||
test_default_values::test();
|
||||
test_save_load::test();
|
||||
test_wstring::test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,39 +1,20 @@
|
||||
#ifndef WRITE_AND_READ_
|
||||
#define WRITE_AND_READ_
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl/bson.hpp>
|
||||
#include <string>
|
||||
|
||||
template <class T>
|
||||
void write_and_read(const T& _struct) {
|
||||
const auto bytes1 = rfl::bson::write(_struct);
|
||||
|
||||
const auto res = rfl::bson::read<T>(bytes1);
|
||||
|
||||
if (!res) {
|
||||
std::cout << "Test failed on read. Error: " << res.error().value().what()
|
||||
<< std::endl
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
const auto bytes2 = rfl::bson::write(res.value());
|
||||
|
||||
if (bytes1.size() != bytes2.size()) {
|
||||
std::cout << "Test failed on write. Number of bytes was different."
|
||||
<< std::endl
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (bytes1 != bytes2) {
|
||||
std::cout << "Test failed on write. Content was not identical." << std::endl
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "OK" << std::endl << std::endl;
|
||||
const auto serialized1 = rfl::bson::write(_struct);
|
||||
const auto res = rfl::bson::read<T>(serialized1);
|
||||
EXPECT_TRUE(res && true) << "Test failed on read. Error: "
|
||||
<< res.error().value().what();
|
||||
const auto serialized2 = rfl::bson::write(res.value());
|
||||
EXPECT_EQ(serialized1, serialized2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
project(reflect-cpp-cbor-tests)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "*.cpp")
|
||||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp")
|
||||
|
||||
add_executable(reflect-cpp-cbor-tests ${SOURCES})
|
||||
add_executable(
|
||||
reflect-cpp-cbor-tests
|
||||
${SOURCES}
|
||||
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc"
|
||||
)
|
||||
|
||||
target_include_directories(reflect-cpp-cbor-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
|
||||
target_include_directories(reflect-cpp-cbor-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/tinycbor")
|
||||
target_link_libraries(reflect-cpp-cbor-tests PRIVATE reflectcpp)
|
||||
|
||||
target_link_libraries(
|
||||
reflect-cpp-cbor-tests
|
||||
PRIVATE
|
||||
reflectcpp
|
||||
"${REFLECT_CPP_GTEST_LIB}"
|
||||
)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_array.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -21,9 +19,7 @@ struct Person {
|
||||
std::unique_ptr<std::array<Person, 3>> children = nullptr;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_array) {
|
||||
auto bart = Person{.first_name = "Bart"};
|
||||
|
||||
auto lisa = Person{.first_name = "Lisa"};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_array{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_box.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -29,9 +27,7 @@ struct DecisionTree {
|
||||
rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_box) {
|
||||
auto leaf1 = DecisionTree::Leaf{.value = 3.0};
|
||||
|
||||
auto leaf2 = DecisionTree::Leaf{.value = 5.0};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_box{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class1.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -31,9 +29,7 @@ struct Person {
|
||||
PersonImpl impl;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_custom_class1) {
|
||||
const auto bart = Person("Bart");
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class1{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class3.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -56,9 +54,7 @@ struct Parser<ReaderType, WriterType, test_custom_class3::Person>
|
||||
|
||||
namespace test_custom_class3 {
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_custom_class3) {
|
||||
const auto bart = Person("Bart", "Simpson", 10);
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class3{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_custom_class4.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -57,9 +55,7 @@ struct Parser<ReaderType, WriterType, test_custom_class4::Person>
|
||||
|
||||
namespace test_custom_class4 {
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_custom_class4) {
|
||||
const auto bart = test_custom_class4::Person(
|
||||
"Bart", rfl::make_box<std::string>("Simpson"), 10);
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_custom_class4{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_default_values.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -17,9 +15,7 @@ struct Person {
|
||||
std::vector<Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_default_values) {
|
||||
const auto bart = Person{.first_name = "Bart"};
|
||||
const auto lisa = Person{.first_name = "Lisa"};
|
||||
const auto maggie = Person{.first_name = "Maggie"};
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_default_values{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_deque.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::deque<Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_default_values) {
|
||||
auto children = std::make_unique<std::deque<Person>>();
|
||||
children->emplace_back(Person{.first_name = "Bart"});
|
||||
children->emplace_back(Person{.first_name = "Lisa"});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_deque{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_enum.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -18,9 +16,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_enum) {
|
||||
const auto circle = Circle{.radius = 2.0, .color = Color::green};
|
||||
|
||||
write_and_read(circle);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_enum {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_field_variant.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -28,9 +26,7 @@ using Shapes = rfl::Variant<rfl::Field<"circle", Circle>,
|
||||
rfl::Field<"rectangle", Rectangle>,
|
||||
rfl::Field<"square", rfl::Box<Square>>>;
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_field_variant) {
|
||||
const Shapes r =
|
||||
rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5});
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_field_variant{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_enum.hpp"
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_flag_enum {
|
||||
@@ -27,9 +26,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_flag_enum) {
|
||||
const auto circle =
|
||||
Circle{.radius = 2.0, .color = Color::blue | Color::orange};
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flag_enum {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "test_enum.hpp"
|
||||
#include "write_and_read.hpp"
|
||||
|
||||
namespace test_flag_enum_with_int {
|
||||
@@ -27,9 +26,7 @@ struct Circle {
|
||||
Color color;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_flag_enum_with_int) {
|
||||
const auto circle = Circle{.radius = 2.0, .color = static_cast<Color>(10000)};
|
||||
|
||||
write_and_read(circle);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flag_enum_with_int {
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_flatten.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -23,9 +21,7 @@ struct Employee {
|
||||
rfl::Field<"salary", float> salary;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_flatten) {
|
||||
const auto employee = Employee{
|
||||
.person = Person{.first_name = "Homer",
|
||||
.last_name = rfl::make_box<std::string>("Simpson"),
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flatten{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_flatten_anonymous.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -23,9 +21,7 @@ struct Employee {
|
||||
float salary;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_flatten_anonymous) {
|
||||
const auto employee = Employee{
|
||||
.person = Person{.first_name = "Homer",
|
||||
.last_name = rfl::make_box<std::string>("Simpson"),
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_flatten_anonymous{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_forward_list.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
#include <source_location>
|
||||
@@ -16,9 +14,7 @@ struct Person {
|
||||
std::unique_ptr<std::forward_list<Person>> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_forward_list) {
|
||||
auto children = std::make_unique<std::forward_list<Person>>();
|
||||
children->emplace_front(Person{.first_name = "Maggie"});
|
||||
children->emplace_front(Person{.first_name = "Lisa"});
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
namespace test_forward_list{
|
||||
void test();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#include "test_literal.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <rfl.hpp>
|
||||
@@ -20,9 +18,7 @@ struct Person {
|
||||
std::vector<Person> children;
|
||||
};
|
||||
|
||||
void test() {
|
||||
std::cout << std::source_location::current().function_name() << std::endl;
|
||||
|
||||
TEST(cbor, test_literal) {
|
||||
const auto bart = Person{.first_name = FirstName::make<"Bart">()};
|
||||
|
||||
write_and_read(bart);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user