diff --git a/tests/json/CMakeLists.txt b/tests/json/CMakeLists.txt index 1e077f6a..b2c8418b 100644 --- a/tests/json/CMakeLists.txt +++ b/tests/json/CMakeLists.txt @@ -2,6 +2,17 @@ project(reflect-cpp-json-tests) file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-json-tests ${SOURCES}) +add_executable( + reflect-cpp-json-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) -target_link_libraries(reflect-cpp-json-tests PRIVATE reflectcpp) +target_include_directories(reflect-cpp-json-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + +target_link_libraries( + reflect-cpp-json-tests + PRIVATE + reflectcpp + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libgtest.a" +) diff --git a/tests/json/test_all_of.cpp b/tests/json/test_all_of.cpp index a296d1a3..49130cdb 100644 --- a/tests/json/test_all_of.cpp +++ b/tests/json/test_all_of.cpp @@ -1,5 +1,3 @@ -#include "test_all_of.hpp" - #include #include #include @@ -22,9 +20,7 @@ struct Person { Age age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_all_of) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/json/test_all_of.hpp b/tests/json/test_all_of.hpp deleted file mode 100644 index 082d508a..00000000 --- a/tests/json/test_all_of.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_all_of{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_alphanumeric_map.cpp b/tests/json/test_alphanumeric_map.cpp index 803a30fc..091cff53 100644 --- a/tests/json/test_alphanumeric_map.cpp +++ b/tests/json/test_alphanumeric_map.cpp @@ -1,5 +1,3 @@ -#include "test_alphanumeric_map.hpp" - #include #include #include @@ -12,9 +10,7 @@ namespace test_alphanumeric_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_alphanumeric_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/json/test_alphanumeric_map.hpp b/tests/json/test_alphanumeric_map.hpp deleted file mode 100644 index 389fdc7b..00000000 --- a/tests/json/test_alphanumeric_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_alphanumeric_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_alphanumeric_unordered_map.cpp b/tests/json/test_alphanumeric_unordered_map.cpp index 3f8bc467..fa9c2790 100644 --- a/tests/json/test_alphanumeric_unordered_map.cpp +++ b/tests/json/test_alphanumeric_unordered_map.cpp @@ -1,5 +1,3 @@ -#include "test_alphanumeric_unordered_map.hpp" - #include #include #include @@ -11,9 +9,7 @@ #include "write_and_read.hpp" namespace test_alphanumeric_unordered_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_alphanumeric_unordered_map) { using Map = std::unordered_map>; Map homer; @@ -26,6 +22,5 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; } } // namespace test_alphanumeric_unordered_map diff --git a/tests/json/test_alphanumeric_unordered_map.hpp b/tests/json/test_alphanumeric_unordered_map.hpp deleted file mode 100644 index d9f85cd2..00000000 --- a/tests/json/test_alphanumeric_unordered_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_alphanumeric_unordered_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_and_then.cpp b/tests/json/test_and_then.cpp index 835fd99c..d33b9ca7 100644 --- a/tests/json/test_and_then.cpp +++ b/tests/json/test_and_then.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,7 +6,6 @@ #include #include -#include "test_replace.hpp" #include "write_and_read.hpp" namespace test_and_then { @@ -18,9 +16,7 @@ struct Person { int age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_and_then) { const auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}; diff --git a/tests/json/test_and_then.hpp b/tests/json/test_and_then.hpp deleted file mode 100644 index 8e0bde5a..00000000 --- a/tests/json/test_and_then.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_and_then { -void test(); -} - diff --git a/tests/json/test_anonymous_fields.cpp b/tests/json/test_anonymous_fields.cpp index 60f98841..08d7210e 100644 --- a/tests/json/test_anonymous_fields.cpp +++ b/tests/json/test_anonymous_fields.cpp @@ -1,5 +1,3 @@ -#include "test_anonymous_fields.hpp" - #include #include #include @@ -23,9 +21,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_anonymous_fields) { const auto bart = Person{.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19", diff --git a/tests/json/test_anonymous_fields.hpp b/tests/json/test_anonymous_fields.hpp deleted file mode 100644 index 16c47d36..00000000 --- a/tests/json/test_anonymous_fields.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_anonymous_fields{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_any_of.cpp b/tests/json/test_any_of.cpp index f0c259f2..9238e4ee 100644 --- a/tests/json/test_any_of.cpp +++ b/tests/json/test_any_of.cpp @@ -1,5 +1,3 @@ -#include "test_any_of.hpp" - #include #include #include @@ -22,9 +20,7 @@ struct Person { Age age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_any_of) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/json/test_any_of.hpp b/tests/json/test_any_of.hpp deleted file mode 100644 index 128c8ebc..00000000 --- a/tests/json/test_any_of.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_any_of{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_apply.cpp b/tests/json/test_apply.cpp index bcb97db7..8b29ac32 100644 --- a/tests/json/test_apply.cpp +++ b/tests/json/test_apply.cpp @@ -7,7 +7,6 @@ #include #include -#include "test_replace.hpp" #include "write_and_read.hpp" namespace test_apply { @@ -18,9 +17,7 @@ struct Person { int age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_apply) { auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}; const auto view = rfl::to_view(lisa); diff --git a/tests/json/test_apply.hpp b/tests/json/test_apply.hpp deleted file mode 100644 index cffdf39e..00000000 --- a/tests/json/test_apply.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_apply { -void test(); -} - diff --git a/tests/json/test_array.cpp b/tests/json/test_array.cpp index 54706e42..dcc9cee4 100644 --- a/tests/json/test_array.cpp +++ b/tests/json/test_array.cpp @@ -1,4 +1,3 @@ -#include "test_array.hpp" #include #include @@ -18,9 +17,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/json/test_array.hpp b/tests/json/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/json/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_as.cpp b/tests/json/test_as.cpp index a5a2d96d..95f578d4 100644 --- a/tests/json/test_as.cpp +++ b/tests/json/test_as.cpp @@ -1,5 +1,3 @@ -#include "test_as.hpp" - #include #include #include @@ -28,8 +26,7 @@ struct C { rfl::Field<"f4", rfl::Box> f4; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; +TEST(json, test_as) { auto a = A{.f1 = "Hello", .f2 = rfl::make_box("World")}; diff --git a/tests/json/test_as.hpp b/tests/json/test_as.hpp deleted file mode 100644 index a2a8e1ab..00000000 --- a/tests/json/test_as.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_as{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_as2.cpp b/tests/json/test_as2.cpp index fe297002..ebc2a666 100644 --- a/tests/json/test_as2.cpp +++ b/tests/json/test_as2.cpp @@ -1,5 +1,3 @@ -#include "test_as2.hpp" - #include #include #include @@ -28,9 +26,7 @@ struct C { rfl::Box f4; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_as2) { auto a = A{.f1 = "Hello", .f2 = rfl::make_box("World")}; auto b = B{.f3 = "Hello", .f4 = rfl::make_box("World")}; diff --git a/tests/json/test_as2.hpp b/tests/json/test_as2.hpp deleted file mode 100644 index 127cd8f3..00000000 --- a/tests/json/test_as2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_as2 { -void test(); -} - diff --git a/tests/json/test_as_flatten.cpp b/tests/json/test_as_flatten.cpp index 17036d5e..375262a9 100644 --- a/tests/json/test_as_flatten.cpp +++ b/tests/json/test_as_flatten.cpp @@ -1,5 +1,3 @@ -#include "test_as_flatten.hpp" - #include #include #include @@ -28,9 +26,7 @@ struct C { int f5; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_as_flatten) { auto a = A{.f1 = "Hello", .f2 = rfl::make_box("World")}; auto b = B{.f3 = "Hello", .f4 = rfl::make_box("World")}; diff --git a/tests/json/test_as_flatten.hpp b/tests/json/test_as_flatten.hpp deleted file mode 100644 index 9b7df9d4..00000000 --- a/tests/json/test_as_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_as_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_box.cpp b/tests/json/test_box.cpp index a7c9090e..b5826ef0 100644 --- a/tests/json/test_box.cpp +++ b/tests/json/test_box.cpp @@ -1,5 +1,3 @@ -#include "test_box.hpp" - #include #include #include @@ -30,9 +28,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/json/test_box.hpp b/tests/json/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/json/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_box2.cpp b/tests/json/test_box2.cpp index 5733948f..d22cfd94 100644 --- a/tests/json/test_box2.cpp +++ b/tests/json/test_box2.cpp @@ -6,22 +6,15 @@ #include #include -#include "test_box.hpp" +#include namespace test_box2 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_box2) { auto ptr = std::make_unique("Hello World!"); const rfl::Result> box = rfl::make_box(std::move(ptr)); - if (box) { - std::cout << "OK" << std::endl << std::endl; - } else { - std::cout << "Expected the result to be successful." << std::endl - << std::endl; - } -} + ASSERT_TRUE(box && true); + } } // namespace test_box2 diff --git a/tests/json/test_box2.hpp b/tests/json/test_box2.hpp deleted file mode 100644 index 63c3c303..00000000 --- a/tests/json/test_box2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box2 { -void test(); -} - diff --git a/tests/json/test_c_array_class1.cpp b/tests/json/test_c_array_class1.cpp index 91de3284..34e3c16c 100644 --- a/tests/json/test_c_array_class1.cpp +++ b/tests/json/test_c_array_class1.cpp @@ -1,5 +1,3 @@ -#include "test_c_array_class1.hpp" - #include #include #include @@ -14,9 +12,7 @@ struct Test1 { std::vector classes[3]; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_c_array_class1) { Test1 test1 = {.classes = {{"Little A", "Little B", "Little C"}, {"BIG A", "BIG B", "BIG C"}, {"??", "$%", "#@"}}}; diff --git a/tests/json/test_c_array_class1.hpp b/tests/json/test_c_array_class1.hpp deleted file mode 100644 index 8bb514e0..00000000 --- a/tests/json/test_c_array_class1.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_c_array_class1 { - -void test(); - -} diff --git a/tests/json/test_c_array_class2.cpp b/tests/json/test_c_array_class2.cpp index e61134ef..c1a93375 100644 --- a/tests/json/test_c_array_class2.cpp +++ b/tests/json/test_c_array_class2.cpp @@ -1,5 +1,3 @@ -#include "test_c_array_class2.hpp" - #include #include #include @@ -15,12 +13,11 @@ struct Test2 { std::string s; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_c_array_class2) { Test2 test2; for (int i = 0; i < 1 << 4; i++) { - test2.multi_dimension_arr[i >> 3 & 1][i >> 2 & 1][i >> 1 & 1][i >> 0 & 1] = i; + test2.multi_dimension_arr[i >> 3 & 1][i >> 2 & 1][i >> 1 & 1][i >> 0 & 1] = + i; } test2.s = "Hello, world!"; @@ -29,4 +26,4 @@ void test() { R"({"multi_dimension_arr":[[[[0,1],[2,3]],[[4,5],[6,7]]],[[[8,9],[10,11]],[[12,13],[14,15]]]],"s":"Hello, world!"})"); } -} // namespace test_c_array +} // namespace test_c_array_class2 diff --git a/tests/json/test_c_array_class2.hpp b/tests/json/test_c_array_class2.hpp deleted file mode 100644 index 9e082e55..00000000 --- a/tests/json/test_c_array_class2.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_c_array_class2 { - -void test(); - -} diff --git a/tests/json/test_c_array_class3.cpp b/tests/json/test_c_array_class3.cpp index b49ce329..25560ff9 100644 --- a/tests/json/test_c_array_class3.cpp +++ b/tests/json/test_c_array_class3.cpp @@ -1,7 +1,5 @@ -#include "test_c_array_class3.hpp" - -#include #include +#include #include "rfl.hpp" #include "rfl/json.hpp" @@ -11,11 +9,9 @@ namespace test_c_array_class3 { using Test3 = std::array[3]; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_c_array_class3) { Test3 test3 = {1, 2, 3, 4, 5, 6, 7, 8, 9}; write_and_read(test3, "[[1,2,3],[4,5,6],[7,8,9]]"); } -} // namespace test_c_array +} // namespace test_c_array_class3 diff --git a/tests/json/test_c_array_class3.hpp b/tests/json/test_c_array_class3.hpp deleted file mode 100644 index 9a2931da..00000000 --- a/tests/json/test_c_array_class3.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_c_array_class3 { - -void test(); - -} diff --git a/tests/json/test_c_array_class4.cpp b/tests/json/test_c_array_class4.cpp index 8ba85777..6e2cd7d4 100644 --- a/tests/json/test_c_array_class4.cpp +++ b/tests/json/test_c_array_class4.cpp @@ -1,5 +1,3 @@ -#include "test_c_array_class4.hpp" - #include #include @@ -15,9 +13,7 @@ struct Test4 { int c[2][2]; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_c_array_class4) { Test4 test4 = {.a = {1, 2, 3}, .b = {4, 5, 6}, .c = {{7, 8}, {9, 10}}}; write_and_read(test4, R"({"a":[1,2,3],"b":[4,5,6],"c":[[7,8],[9,10]]})"); diff --git a/tests/json/test_c_array_class4.hpp b/tests/json/test_c_array_class4.hpp deleted file mode 100644 index 32857ec4..00000000 --- a/tests/json/test_c_array_class4.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_c_array_class4 { - -void test(); - -} diff --git a/tests/json/test_c_array_class5.cpp b/tests/json/test_c_array_class5.cpp index 55fe7b29..375b0985 100644 --- a/tests/json/test_c_array_class5.cpp +++ b/tests/json/test_c_array_class5.cpp @@ -1,5 +1,3 @@ -#include "test_c_array_class5.hpp" - #include #include @@ -15,9 +13,7 @@ struct Test5 { int c[2][2]; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_c_array_class5) { Test5 t1 = {.a = {1, 2, 3}, .b = {4, 5, 6}, .c = {{7, 8}, {9, 10}}}; const auto t2 = rfl::replace(t1, rfl::make_field<"b", int[3]>({1, 2, 3})); diff --git a/tests/json/test_c_array_class5.hpp b/tests/json/test_c_array_class5.hpp deleted file mode 100644 index 4b87e475..00000000 --- a/tests/json/test_c_array_class5.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_c_array_class5 { - -void test(); - -} diff --git a/tests/json/test_const_fields.cpp b/tests/json/test_const_fields.cpp index 26537888..f3dcb697 100644 --- a/tests/json/test_const_fields.cpp +++ b/tests/json/test_const_fields.cpp @@ -1,5 +1,3 @@ -#include "test_const_fields.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Person { const std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_const_fields) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/json/test_const_fields.hpp b/tests/json/test_const_fields.hpp deleted file mode 100644 index 1bfeacb9..00000000 --- a/tests/json/test_const_fields.hpp +++ /dev/null @@ -1,5 +0,0 @@ -namespace test_const_fields { - -void test(); - -} diff --git a/tests/json/test_custom_class1.cpp b/tests/json/test_custom_class1.cpp index 2e14e575..e112340f 100644 --- a/tests/json/test_custom_class1.cpp +++ b/tests/json/test_custom_class1.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class1.hpp" - #include #include #include @@ -32,8 +30,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; +TEST(json, test_custom_class1) { const auto bart = Person("Bart"); diff --git a/tests/json/test_custom_class1.hpp b/tests/json/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/json/test_custom_class1.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_class1{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_custom_class2.cpp b/tests/json/test_custom_class2.cpp index adfa1021..86582980 100644 --- a/tests/json/test_custom_class2.cpp +++ b/tests/json/test_custom_class2.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class2.hpp" - #include #include #include @@ -31,15 +29,10 @@ struct FiveDigitCode { int code; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_custom_class2) { const auto result = rfl::json::read("123"); - if (result) { - std::cout << "Failed: Expected an error, but got none." << std::endl; - return; - } + EXPECT_TRUE(!result && true); const auto c = FiveDigitCode(12345); diff --git a/tests/json/test_custom_class2.hpp b/tests/json/test_custom_class2.hpp deleted file mode 100644 index 21cfbd51..00000000 --- a/tests/json/test_custom_class2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_class2{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_custom_class3.cpp b/tests/json/test_custom_class3.cpp index 5da2c207..c476b555 100644 --- a/tests/json/test_custom_class3.cpp +++ b/tests/json/test_custom_class3.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class3.hpp" - #include #include #include @@ -57,9 +55,7 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart, R"({"firstName":"Bart","lastName":"Simpson","age":10})"); diff --git a/tests/json/test_custom_class3.hpp b/tests/json/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/json/test_custom_class3.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_class3{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_custom_class4.cpp b/tests/json/test_custom_class4.cpp index 7057cbdf..4e83124f 100644 --- a/tests/json/test_custom_class4.cpp +++ b/tests/json/test_custom_class4.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class4.hpp" - #include #include #include @@ -58,9 +56,7 @@ struct Parser namespace test_custom_class4 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/json/test_custom_class4.hpp b/tests/json/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/json/test_custom_class4.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_class4{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_custom_constructor.cpp b/tests/json/test_custom_constructor.cpp index 28ec28dc..0c614806 100644 --- a/tests/json/test_custom_constructor.cpp +++ b/tests/json/test_custom_constructor.cpp @@ -1,5 +1,3 @@ -#include "test_custom_constructor.hpp" - #include #include #include @@ -32,24 +30,12 @@ struct Person { rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_custom_constructor) { const auto res = rfl::json::read( R"({"firstName":"Homer","lastName":"Simpson","birthday":"1987-04-19"})"); - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl; - return; - } + EXPECT_TRUE (res && true); - if (res.value().first_name() != "Bart") { - std::cout << "Expected 'Bart', got '" << res.value().first_name() << "'" - << std::endl - << std::endl; - } else { - std::cout << "OK" << std::endl << std::endl; - } + EXPECT_EQ(res.value().first_name(), "Bart"); } } // namespace test_custom_constructor diff --git a/tests/json/test_custom_constructor.hpp b/tests/json/test_custom_constructor.hpp deleted file mode 100644 index 013721d0..00000000 --- a/tests/json/test_custom_constructor.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_constructor{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_default_values.cpp b/tests/json/test_default_values.cpp index a8105197..db69e1b7 100644 --- a/tests/json/test_default_values.cpp +++ b/tests/json/test_default_values.cpp @@ -1,5 +1,3 @@ -#include "test_default_values.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_default_values) { const auto bart = Person{.first_name = "Bart"}; const auto lisa = Person{.first_name = "Lisa"}; const auto maggie = Person{.first_name = "Maggie"}; diff --git a/tests/json/test_default_values.hpp b/tests/json/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/json/test_default_values.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_default_values{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_deque.cpp b/tests/json/test_deque.cpp index 059a9a7f..dca0e9f7 100644 --- a/tests/json/test_deque.cpp +++ b/tests/json/test_deque.cpp @@ -1,5 +1,3 @@ -#include "test_deque.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_deque) { auto children = std::make_unique>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); diff --git a/tests/json/test_deque.hpp b/tests/json/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/json/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_email.cpp b/tests/json/test_email.cpp index 861963e2..0498075f 100644 --- a/tests/json/test_email.cpp +++ b/tests/json/test_email.cpp @@ -1,5 +1,3 @@ -#include "test_email.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { rfl::Email email; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_email) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .email = "homer@simpson.com"}; diff --git a/tests/json/test_email.hpp b/tests/json/test_email.hpp deleted file mode 100644 index 3d9e15a0..00000000 --- a/tests/json/test_email.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_email{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_empty_object.cpp b/tests/json/test_empty_object.cpp index 7e294224..84ad6949 100644 --- a/tests/json/test_empty_object.cpp +++ b/tests/json/test_empty_object.cpp @@ -1,5 +1,3 @@ -#include "test_empty_object.hpp" - #include #include #include @@ -13,9 +11,7 @@ namespace test_empty_object { struct Empty {}; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_empty_object) { const auto empty = Empty{}; write_and_read(empty, R"({})"); diff --git a/tests/json/test_empty_object.hpp b/tests/json/test_empty_object.hpp deleted file mode 100644 index 8eea4ddd..00000000 --- a/tests/json/test_empty_object.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_empty_object { -void test(); -} - diff --git a/tests/json/test_enum1.cpp b/tests/json/test_enum1.cpp index 358a4eb1..27960a6b 100644 --- a/tests/json/test_enum1.cpp +++ b/tests/json/test_enum1.cpp @@ -1,5 +1,3 @@ -#include "test_enum1.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum1) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle, R"({"radius":2.0,"color":"green"})"); diff --git a/tests/json/test_enum1.hpp b/tests/json/test_enum1.hpp deleted file mode 100644 index 97af2fb1..00000000 --- a/tests/json/test_enum1.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum1 { -void test(); -} - diff --git a/tests/json/test_enum2.cpp b/tests/json/test_enum2.cpp index 7a9514bd..d1026439 100644 --- a/tests/json/test_enum2.cpp +++ b/tests/json/test_enum2.cpp @@ -1,5 +1,3 @@ -#include "test_enum2.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum2) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::green}; if (auto color = rfl::string_to_enum("red"); color) { diff --git a/tests/json/test_enum2.hpp b/tests/json/test_enum2.hpp deleted file mode 100644 index 7941d5e9..00000000 --- a/tests/json/test_enum2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum2 { -void test(); -} - diff --git a/tests/json/test_enum3.cpp b/tests/json/test_enum3.cpp index 77b1ffff..84a17a73 100644 --- a/tests/json/test_enum3.cpp +++ b/tests/json/test_enum3.cpp @@ -1,5 +1,3 @@ -#include "test_enum3.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum3) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::red}; if (auto color = rfl::string_to_enum("bart"); color) { diff --git a/tests/json/test_enum3.hpp b/tests/json/test_enum3.hpp deleted file mode 100644 index 4bf7efab..00000000 --- a/tests/json/test_enum3.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum3 { -void test(); -} - diff --git a/tests/json/test_enum4.cpp b/tests/json/test_enum4.cpp index 7be74536..3afc184e 100644 --- a/tests/json/test_enum4.cpp +++ b/tests/json/test_enum4.cpp @@ -1,5 +1,3 @@ -#include "test_enum4.hpp" - #include #include #include @@ -19,8 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; +TEST(json, test_enum4) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::red}; diff --git a/tests/json/test_enum4.hpp b/tests/json/test_enum4.hpp deleted file mode 100644 index 070d7b81..00000000 --- a/tests/json/test_enum4.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum4 { -void test(); -} - diff --git a/tests/json/test_enum5.cpp b/tests/json/test_enum5.cpp index 3673011f..3040dc7a 100644 --- a/tests/json/test_enum5.cpp +++ b/tests/json/test_enum5.cpp @@ -1,5 +1,3 @@ -#include "test_enum5.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum5) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::blue}; rfl::get_enumerators().apply([&](auto field) { diff --git a/tests/json/test_enum5.hpp b/tests/json/test_enum5.hpp deleted file mode 100644 index 1d7854eb..00000000 --- a/tests/json/test_enum5.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum5 { -void test(); -} - diff --git a/tests/json/test_enum6.cpp b/tests/json/test_enum6.cpp index 1afb8b0b..a79e4616 100644 --- a/tests/json/test_enum6.cpp +++ b/tests/json/test_enum6.cpp @@ -1,5 +1,3 @@ -#include "test_enum6.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum6) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::red}; rfl::get_underlying_enumerators().apply([&](const auto& field) { diff --git a/tests/json/test_enum6.hpp b/tests/json/test_enum6.hpp deleted file mode 100644 index 5c8023f4..00000000 --- a/tests/json/test_enum6.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum6 { -void test(); -} - diff --git a/tests/json/test_enum7.cpp b/tests/json/test_enum7.cpp index 0d78a754..a483410f 100644 --- a/tests/json/test_enum7.cpp +++ b/tests/json/test_enum7.cpp @@ -1,5 +1,3 @@ -#include "test_enum7.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include #include -#include "write_and_read.hpp" +#include namespace test_enum7 { @@ -19,9 +17,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_enum7) { constexpr auto enumerator_array = rfl::get_enumerator_array(); static_assert(enumerator_array[0].first == "red"); static_assert(enumerator_array[1].first == "green"); @@ -44,7 +40,7 @@ void test() { static_assert(enumerator_array_underlying[3].second == 3); // This is a compile-time test - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(true); } } // namespace test_enum7 diff --git a/tests/json/test_enum7.hpp b/tests/json/test_enum7.hpp deleted file mode 100644 index b8be5df5..00000000 --- a/tests/json/test_enum7.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum7 { -void test(); -} - diff --git a/tests/json/test_error_messages.cpp b/tests/json/test_error_messages.cpp index aa475a1d..3f224c37 100644 --- a/tests/json/test_error_messages.cpp +++ b/tests/json/test_error_messages.cpp @@ -1,5 +1,3 @@ -#include "test_error_messages.hpp" - #include #include #include @@ -7,7 +5,7 @@ #include #include -#include "write_and_read.hpp" +#include namespace test_error_messages { @@ -18,9 +16,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_error_messages) { const std::string faulty_string = R"({"firstName":"Homer","lastName":12345,"birthday":"04/19/1987"})"; @@ -31,18 +27,8 @@ void test() { 2) Failed to parse field 'birthday': String '04/19/1987' did not match format '%Y-%m-%d'. 3) Field named 'children' not found.)"; - if (!result.error()) { - std::cout << "Expected an error, got none." << std::endl << std::endl; - } - - if (result.error().value().what() != expected) { - std::cout << "Expected: " << std::endl - << expected << std::endl - << "Got:" << std::endl - << result.error().value().what() << std::endl - << std::endl; - } + EXPECT_TRUE(result.error() && true); - std::cout << "OK" << std::endl << std::endl; + EXPECT_EQ(result.error().value().what(), expected); } } // namespace test_error_messages diff --git a/tests/json/test_error_messages.hpp b/tests/json/test_error_messages.hpp deleted file mode 100644 index 726d24a3..00000000 --- a/tests/json/test_error_messages.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_error_messages{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_field_variant.cpp b/tests/json/test_field_variant.cpp index 75543dcb..b8076c52 100644 --- a/tests/json/test_field_variant.cpp +++ b/tests/json/test_field_variant.cpp @@ -1,5 +1,3 @@ -#include "test_field_variant.hpp" - #include #include #include @@ -29,9 +27,7 @@ using Shapes = rfl::Variant, rfl::Field<"rectangle", Rectangle>, rfl::Field<"square", rfl::Box>>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/json/test_field_variant.hpp b/tests/json/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/json/test_field_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_field_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_flag_enum1.cpp b/tests/json/test_flag_enum1.cpp index ad35b0bb..c02afb8c 100644 --- a/tests/json/test_flag_enum1.cpp +++ b/tests/json/test_flag_enum1.cpp @@ -1,5 +1,3 @@ -#include "test_flag_enum1.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_flag_enum1) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/json/test_flag_enum1.hpp b/tests/json/test_flag_enum1.hpp deleted file mode 100644 index cafcff27..00000000 --- a/tests/json/test_flag_enum1.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum1 { -void test(); -} - diff --git a/tests/json/test_flag_enum2.cpp b/tests/json/test_flag_enum2.cpp index 4b5fc1ab..1aa6ce07 100644 --- a/tests/json/test_flag_enum2.cpp +++ b/tests/json/test_flag_enum2.cpp @@ -1,5 +1,3 @@ -#include "test_flag_enum2.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_flag_enum2) { auto mutable_circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/json/test_flag_enum2.hpp b/tests/json/test_flag_enum2.hpp deleted file mode 100644 index 55a52008..00000000 --- a/tests/json/test_flag_enum2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum2 { -void test(); -} - diff --git a/tests/json/test_flag_enum_with_int.cpp b/tests/json/test_flag_enum_with_int.cpp index 63c1e4b6..5c3381f5 100644 --- a/tests/json/test_flag_enum_with_int.cpp +++ b/tests/json/test_flag_enum_with_int.cpp @@ -1,5 +1,3 @@ -#include "test_flag_enum_with_int.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle, R"({"radius":2.0,"color":"16|red|green|blue|8192"})"); diff --git a/tests/json/test_flag_enum_with_int.hpp b/tests/json/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/json/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/json/test_flatten.cpp b/tests/json/test_flatten.cpp index e4437ba1..ee8957e9 100644 --- a/tests/json/test_flatten.cpp +++ b/tests/json/test_flatten.cpp @@ -1,5 +1,3 @@ -#include "test_flatten.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { rfl::Field<"salary", float> salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/json/test_flatten.hpp b/tests/json/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/json/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_flatten_anonymous.cpp b/tests/json/test_flatten_anonymous.cpp index 21c7c809..3b9fa0b2 100644 --- a/tests/json/test_flatten_anonymous.cpp +++ b/tests/json/test_flatten_anonymous.cpp @@ -1,5 +1,3 @@ -#include "test_flatten_anonymous.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/json/test_flatten_anonymous.hpp b/tests/json/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/json/test_flatten_anonymous.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten_anonymous{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_forward_list.cpp b/tests/json/test_forward_list.cpp index d46ef96f..173fc15a 100644 --- a/tests/json/test_forward_list.cpp +++ b/tests/json/test_forward_list.cpp @@ -1,5 +1,3 @@ -#include "test_forward_list.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_forward_list) { auto children = std::make_unique>(); children->emplace_front(Person{.first_name = "Maggie"}); children->emplace_front(Person{.first_name = "Lisa"}); diff --git a/tests/json/test_forward_list.hpp b/tests/json/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/json/test_forward_list.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_forward_list{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_inheritance.cpp b/tests/json/test_inheritance.cpp index 1852f21b..227c3926 100644 --- a/tests/json/test_inheritance.cpp +++ b/tests/json/test_inheritance.cpp @@ -4,11 +4,11 @@ #include #include -namespace test_inheritance { +#include -void test() { - std::cout << std::source_location::current().function_name() << std::endl; +namespace test_inheritance { +TEST(json, test_inheritance) { struct S { int x; }; @@ -20,7 +20,7 @@ void test() { static_assert(name == "x"); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(true); } } // namespace test_inheritance diff --git a/tests/json/test_inheritance.hpp b/tests/json/test_inheritance.hpp deleted file mode 100644 index 31d51d1a..00000000 --- a/tests/json/test_inheritance.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_inheritance{ -void test(); -} diff --git a/tests/json/test_inheritance2.cpp b/tests/json/test_inheritance2.cpp index 21b8475a..ada6c8d5 100644 --- a/tests/json/test_inheritance2.cpp +++ b/tests/json/test_inheritance2.cpp @@ -5,6 +5,8 @@ #include "rfl/internal/num_fields.hpp" +#include + namespace test_inheritance2 { struct EmptyBase1 {}; @@ -27,9 +29,7 @@ struct EmptyDerived0 : BaseX, EmptyBase1 {}; struct EmptyDerived1 : EmptyBase1, BaseX {}; struct EmptyDerived2 : EmptyBase1, EmptyBase2, BaseX {}; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_inheritance2) { Derived1 derived1; const auto derived1_view = rfl::to_view(derived1); static_assert(derived1_view.size() == 2); @@ -50,7 +50,7 @@ void test() { auto empty_derived2_view = rfl::to_view(empty_derived2); static_assert(empty_derived0_view.size() == 2); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(true); } } // namespace test_inheritance2 diff --git a/tests/json/test_inheritance2.hpp b/tests/json/test_inheritance2.hpp deleted file mode 100644 index c347aac6..00000000 --- a/tests/json/test_inheritance2.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_inheritance2 { -void test(); -} diff --git a/tests/json/test_inside_function.cpp b/tests/json/test_inside_function.cpp index 76a11cee..4166075b 100644 --- a/tests/json/test_inside_function.cpp +++ b/tests/json/test_inside_function.cpp @@ -1,5 +1,3 @@ -#include "test_inside_function.hpp" - #include #include #include @@ -11,9 +9,7 @@ namespace test_inside_function { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_inside_function) { using Age = rfl::Validator, rfl::Maximum<130>>; struct Person { diff --git a/tests/json/test_inside_function.hpp b/tests/json/test_inside_function.hpp deleted file mode 100644 index e7cf82f6..00000000 --- a/tests/json/test_inside_function.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_inside_function { -void test(); -} - diff --git a/tests/json/test_json_schema.cpp b/tests/json/test_json_schema.cpp index f51b48b3..ab3ae224 100644 --- a/tests/json/test_json_schema.cpp +++ b/tests/json/test_json_schema.cpp @@ -7,7 +7,6 @@ #include #include -#include "test_readme_example.hpp" #include "write_and_read.hpp" namespace test_json_schema { @@ -55,9 +54,7 @@ struct Person { rfl::Rename<"fieldVariant", FieldVariant> field_variant; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_json_schema) { const auto json_schema = rfl::json::to_schema< rfl::Description<"JSON schema that describes the required " "attributes for the person class.", @@ -66,16 +63,6 @@ void test() { const std::string expected = R"({"$schema":"https://json-schema.org/draft/2020-12/schema","$ref":"#/definitions/test_json_schema__Person","description":"JSON schema that describes the required attributes for the person class.","definitions":{"test_json_schema__Circle":{"type":"object","properties":{"radius":{"type":"number"}},"required":["radius"]},"test_json_schema__Circle__tagged":{"type":"object","properties":{"radius":{"type":"number"},"shape":{"type":"string","enum":["Circle"]}},"required":["radius","shape"]},"test_json_schema__Person":{"type":"object","properties":{"age":{"allOf":[{"minimum":0,"type":"integer"},{"maximum":130,"type":"integer"}]},"children":{"type":"array","description":"The person's children. Pass an empty array for no children.","items":{"$ref":"#/definitions/test_json_schema__Person"}},"color":{"type":"string","enum":["red","green","blue"]},"email":{"type":"string","description":"Must be a proper email in the form xxx@xxx.xxx.","pattern":"^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$"},"fieldVariant":{"anyOf":[{"type":"object","properties":{"rectangle":{"$ref":"#/definitions/test_json_schema__Rectangle"}},"required":["rectangle"]},{"type":"object","properties":{"square":{"$ref":"#/definitions/test_json_schema__Square"}},"required":["square"]},{"type":"object","properties":{"circle":{"$ref":"#/definitions/test_json_schema__Circle"}},"required":["circle"]}]},"firstName":{"type":"string"},"lastName":{"type":"string"},"salary":{"type":"number"},"taggedUnion":{"anyOf":[{"$ref":"#/definitions/test_json_schema__Rectangle__tagged"},{"$ref":"#/definitions/test_json_schema__Square__tagged"},{"$ref":"#/definitions/test_json_schema__Circle__tagged"}]},"town":{"type":"string"},"tuple":{"type":"array","prefixItems":[{"type":"string","enum":["red","green","blue"]},{"type":"array","items":{"$ref":"#/definitions/test_json_schema__Person"}},{"type":"integer"}],"items":false},"variant":{"anyOf":[{"type":"string","enum":["red","green","blue"]},{"type":"array","items":{"$ref":"#/definitions/test_json_schema__Person"}},{"type":"integer"}]}},"required":["age","children","color","email","fieldVariant","firstName","lastName","salary","taggedUnion","town","tuple","variant"]},"test_json_schema__Rectangle":{"type":"object","properties":{"height":{"type":"number"},"width":{"type":"number"}},"required":["height","width"]},"test_json_schema__Rectangle__tagged":{"type":"object","properties":{"height":{"type":"number"},"shape":{"type":"string","enum":["Rectangle"]},"width":{"type":"number"}},"required":["height","shape","width"]},"test_json_schema__Square":{"type":"object","properties":{"width":{"type":"number"}},"required":["width"]},"test_json_schema__Square__tagged":{"type":"object","properties":{"shape":{"type":"string","enum":["Square"]},"width":{"type":"number"}},"required":["shape","width"]}}})"; - if (json_schema != expected) { - std::cout << "Test failed. Expected:" << std::endl - << expected << std::endl - << "Got: " << std::endl - << json_schema << std::endl - << std::endl; - - return; - } - - std::cout << "OK" << std::endl << std::endl; + EXPECT_EQ(json_schema, expected); } } // namespace test_json_schema diff --git a/tests/json/test_json_schema.hpp b/tests/json/test_json_schema.hpp deleted file mode 100644 index ec30a8ba..00000000 --- a/tests/json/test_json_schema.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_json_schema { -void test(); -} - diff --git a/tests/json/test_list.cpp b/tests/json/test_list.cpp index cffb8f52..dfa9ce9a 100644 --- a/tests/json/test_list.cpp +++ b/tests/json/test_list.cpp @@ -1,5 +1,3 @@ -#include "test_list.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_list) { auto children = std::make_unique>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); diff --git a/tests/json/test_list.hpp b/tests/json/test_list.hpp deleted file mode 100644 index 956d36cc..00000000 --- a/tests/json/test_list.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_list{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_literal.cpp b/tests/json/test_literal.cpp index c695c552..e51818ce 100644 --- a/tests/json/test_literal.cpp +++ b/tests/json/test_literal.cpp @@ -1,5 +1,3 @@ -#include "test_literal.hpp" - #include #include #include @@ -21,9 +19,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart, diff --git a/tests/json/test_literal.hpp b/tests/json/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/json/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_literal_map.cpp b/tests/json/test_literal_map.cpp index 5f6afa8f..c7e50fc3 100644 --- a/tests/json/test_literal_map.cpp +++ b/tests/json/test_literal_map.cpp @@ -1,5 +1,3 @@ -#include "test_literal_map.hpp" - #include #include #include @@ -15,9 +13,7 @@ namespace test_literal_map { using FieldName = rfl::Literal<"firstName", "lastName">; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/json/test_literal_map.hpp b/tests/json/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/json/test_literal_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_literal_unordered_map.cpp b/tests/json/test_literal_unordered_map.cpp index 9dfb6334..31e4d5f8 100644 --- a/tests/json/test_literal_unordered_map.cpp +++ b/tests/json/test_literal_unordered_map.cpp @@ -1,5 +1,3 @@ -#include "test_literal_unordered_map.hpp" - #include #include #include @@ -18,9 +16,7 @@ using FieldName = rfl::Literal<"firstName", "lastName">; using Map = std::unordered_map>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_literal_unordered_map) { Map homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), @@ -32,6 +28,7 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + + EXPECT_TRUE(true); } } // namespace test_literal_unordered_map diff --git a/tests/json/test_literal_unordered_map.hpp b/tests/json/test_literal_unordered_map.hpp deleted file mode 100644 index 870a82c3..00000000 --- a/tests/json/test_literal_unordered_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal_unordered_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_map.cpp b/tests/json/test_map.cpp index 20a227ea..b8f8eb34 100644 --- a/tests/json/test_map.cpp +++ b/tests/json/test_map.cpp @@ -1,5 +1,3 @@ -#include "test_map.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_map) { auto children = std::make_unique>(); children->insert(std::make_pair(1, Person{.first_name = "Bart"})); children->insert(std::make_pair(2, Person{.first_name = "Lisa"})); diff --git a/tests/json/test_map.hpp b/tests/json/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/json/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_map_with_key_validation.cpp b/tests/json/test_map_with_key_validation.cpp index 994cfddc..fdffdc76 100644 --- a/tests/json/test_map_with_key_validation.cpp +++ b/tests/json/test_map_with_key_validation.cpp @@ -1,5 +1,3 @@ -#include "test_map_with_key_validation.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair(1, Person{.first_name = "Bart"})); diff --git a/tests/json/test_map_with_key_validation.hpp b/tests/json/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/json/test_map_with_key_validation.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map_with_key_validation{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_meta_fields.cpp b/tests/json/test_meta_fields.cpp index 1d759a89..04000212 100644 --- a/tests/json/test_meta_fields.cpp +++ b/tests/json/test_meta_fields.cpp @@ -1,8 +1,8 @@ -#include "test_meta_fields.hpp" - #include #include +#include + namespace test_meta_fields { struct Person { @@ -13,21 +13,9 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_meta_fields) { const auto fields = rfl::fields(); - /*std::cout << "Fields in " << rfl::type_name_t().str() << ":" - << std::endl; - for (const auto& f : fields) { - std::cout << "name: " << f.name() << ", type: " << f.type() << std::endl; - }*/ - - // The exact content is somewhat unpredictable, we just want to make sure it - // compiles. - if (fields.size() == 5) { - std::cout << "OK" << std::endl << std::endl; - } + EXPECT_EQ(fields.size(), 5); } } // namespace test_meta_fields diff --git a/tests/json/test_meta_fields.hpp b/tests/json/test_meta_fields.hpp deleted file mode 100644 index 903af004..00000000 --- a/tests/json/test_meta_fields.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_meta_fields { -void test(); -} - diff --git a/tests/json/test_monster_example.cpp b/tests/json/test_monster_example.cpp index 8887e249..84a7bd13 100644 --- a/tests/json/test_monster_example.cpp +++ b/tests/json/test_monster_example.cpp @@ -1,5 +1,3 @@ -#include "test_monster_example.hpp" - #include #include #include @@ -39,9 +37,7 @@ struct Monster { std::vector path; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/json/test_monster_example.hpp b/tests/json/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/json/test_monster_example.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_monster_example{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_move_replace.cpp b/tests/json/test_move_replace.cpp index e4e15ba2..6410b646 100644 --- a/tests/json/test_move_replace.cpp +++ b/tests/json/test_move_replace.cpp @@ -1,5 +1,3 @@ -#include "test_move_replace.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Person { rfl::Field<"children", rfl::Box>> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_move_replace) { auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .children = rfl::make_box>()}; diff --git a/tests/json/test_move_replace.hpp b/tests/json/test_move_replace.hpp deleted file mode 100644 index 07704631..00000000 --- a/tests/json/test_move_replace.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_move_replace{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_multimap.cpp b/tests/json/test_multimap.cpp index cb74d75b..42f3469c 100644 --- a/tests/json/test_multimap.cpp +++ b/tests/json/test_multimap.cpp @@ -1,5 +1,3 @@ -#include "test_multimap.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_multimap) { auto children = std::make_unique>(); children->insert(std::make_pair(1, Person{.first_name = "Bart"})); children->insert(std::make_pair(2, Person{.first_name = "Lisa"})); diff --git a/tests/json/test_multimap.hpp b/tests/json/test_multimap.hpp deleted file mode 100644 index 81845572..00000000 --- a/tests/json/test_multimap.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_multimap{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_multiset.cpp b/tests/json/test_multiset.cpp index 923144f0..e410b633 100644 --- a/tests/json/test_multiset.cpp +++ b/tests/json/test_multiset.cpp @@ -1,5 +1,3 @@ -#include "test_multiset.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_multiset) { auto children = std::make_unique>( std::multiset({"Bart", "Lisa", "Maggie"})); diff --git a/tests/json/test_multiset.hpp b/tests/json/test_multiset.hpp deleted file mode 100644 index adfcf186..00000000 --- a/tests/json/test_multiset.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_multiset{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_one_of.cpp b/tests/json/test_one_of.cpp index d554d37d..66333cd0 100644 --- a/tests/json/test_one_of.cpp +++ b/tests/json/test_one_of.cpp @@ -1,5 +1,3 @@ -#include "test_one_of.hpp" - #include #include #include @@ -22,9 +20,7 @@ struct Person { Age age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_one_of) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/json/test_one_of.hpp b/tests/json/test_one_of.hpp deleted file mode 100644 index 47b4e262..00000000 --- a/tests/json/test_one_of.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_one_of{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_optional_fields.cpp b/tests/json/test_optional_fields.cpp index dfedddbf..53895a52 100644 --- a/tests/json/test_optional_fields.cpp +++ b/tests/json/test_optional_fields.cpp @@ -1,5 +1,3 @@ -#include "test_optional_fields.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { rfl::Rename<"children", std::optional>> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, insert_name_here) { const auto bart = Person{.first_name = "Bart"}; const auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/json/test_optional_fields.hpp b/tests/json/test_optional_fields.hpp deleted file mode 100644 index 640cab95..00000000 --- a/tests/json/test_optional_fields.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_optional_fields{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_readme_example.cpp b/tests/json/test_readme_example.cpp index 3eef7acc..e50a8c52 100644 --- a/tests/json/test_readme_example.cpp +++ b/tests/json/test_readme_example.cpp @@ -1,5 +1,3 @@ -#include "test_readme_example.hpp" - #include #include #include @@ -23,9 +21,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/json/test_readme_example.hpp b/tests/json/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/json/test_readme_example.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_ref.cpp b/tests/json/test_ref.cpp index e3d3d23c..873e4264 100644 --- a/tests/json/test_ref.cpp +++ b/tests/json/test_ref.cpp @@ -1,5 +1,3 @@ -#include "test_ref.hpp" - #include #include #include @@ -30,9 +28,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/json/test_ref.hpp b/tests/json/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/json/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_replace.cpp b/tests/json/test_replace.cpp index 7c555e8d..f19ff14d 100644 --- a/tests/json/test_replace.cpp +++ b/tests/json/test_replace.cpp @@ -1,5 +1,3 @@ -#include "test_replace.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Person { rfl::Field<"children", rfl::Box>> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace) { auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .children = rfl::make_box>()}; diff --git a/tests/json/test_replace.hpp b/tests/json/test_replace.hpp deleted file mode 100644 index 9d421218..00000000 --- a/tests/json/test_replace.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_replace2.cpp b/tests/json/test_replace2.cpp index 79f0c46c..54214562 100644 --- a/tests/json/test_replace2.cpp +++ b/tests/json/test_replace2.cpp @@ -1,5 +1,3 @@ -#include "test_replace2.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Person { rfl::Box> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace2) { auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .children = rfl::make_box>()}; diff --git a/tests/json/test_replace2.hpp b/tests/json/test_replace2.hpp deleted file mode 100644 index 0dff70b7..00000000 --- a/tests/json/test_replace2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace2 { -void test(); -} - diff --git a/tests/json/test_replace_flatten.cpp b/tests/json/test_replace_flatten.cpp index e57e8b88..59f9e54c 100644 --- a/tests/json/test_replace_flatten.cpp +++ b/tests/json/test_replace_flatten.cpp @@ -1,5 +1,3 @@ -#include "test_replace_flatten.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { rfl::Field<"salary", float> salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace_flatten) { auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/json/test_replace_flatten.hpp b/tests/json/test_replace_flatten.hpp deleted file mode 100644 index 5bc5f716..00000000 --- a/tests/json/test_replace_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_replace_flatten2.cpp b/tests/json/test_replace_flatten2.cpp index bb92ebcf..95300fdc 100644 --- a/tests/json/test_replace_flatten2.cpp +++ b/tests/json/test_replace_flatten2.cpp @@ -1,5 +1,3 @@ -#include "test_replace_flatten2.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace_flatten2) { auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/json/test_replace_flatten2.hpp b/tests/json/test_replace_flatten2.hpp deleted file mode 100644 index f31356ce..00000000 --- a/tests/json/test_replace_flatten2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace_flatten2 { -void test(); -} - diff --git a/tests/json/test_replace_with_other_struct.cpp b/tests/json/test_replace_with_other_struct.cpp index eb9e8f78..02526205 100644 --- a/tests/json/test_replace_with_other_struct.cpp +++ b/tests/json/test_replace_with_other_struct.cpp @@ -1,5 +1,3 @@ -#include "test_replace_with_other_struct.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { rfl::Field<"salary", float> salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace_with_other_struct) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}, diff --git a/tests/json/test_replace_with_other_struct.hpp b/tests/json/test_replace_with_other_struct.hpp deleted file mode 100644 index 1315603a..00000000 --- a/tests/json/test_replace_with_other_struct.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace_with_other_struct{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_replace_with_other_struct2.cpp b/tests/json/test_replace_with_other_struct2.cpp index ce2b5545..71fbae07 100644 --- a/tests/json/test_replace_with_other_struct2.cpp +++ b/tests/json/test_replace_with_other_struct2.cpp @@ -1,5 +1,3 @@ -#include "test_replace_with_other_struct2.hpp" - #include #include #include @@ -24,9 +22,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_replace_with_other_struct2) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}, diff --git a/tests/json/test_replace_with_other_struct2.hpp b/tests/json/test_replace_with_other_struct2.hpp deleted file mode 100644 index ab579406..00000000 --- a/tests/json/test_replace_with_other_struct2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_replace_with_other_struct2 { -void test(); -} - diff --git a/tests/json/test_result.cpp b/tests/json/test_result.cpp index 1db7f4c7..fa44361a 100644 --- a/tests/json/test_result.cpp +++ b/tests/json/test_result.cpp @@ -1,5 +1,3 @@ -#include "test_result.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::vector> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_result) { const rfl::Result bart = Person{.first_name = "Bart"}; const rfl::Result lisa = Person{.first_name = "Lisa"}; diff --git a/tests/json/test_result.hpp b/tests/json/test_result.hpp deleted file mode 100644 index 170943c5..00000000 --- a/tests/json/test_result.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_result{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_save_load.cpp b/tests/json/test_save_load.cpp index 43f36a70..fe2fda48 100644 --- a/tests/json/test_save_load.cpp +++ b/tests/json/test_save_load.cpp @@ -1,5 +1,3 @@ -#include "test_save_load.hpp" - #include #include #include @@ -8,6 +6,8 @@ #include #include +#include + namespace test_save_load { using Age = rfl::Validator children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_save_load) { const auto bart = Person{.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19", @@ -59,12 +57,7 @@ void test() { const auto string1 = rfl::json::write(homer1); const auto string2 = rfl::json::write(homer2); - if (string1 != string2) { - std::cout << "Test failed. Content was not identical." << std::endl + EXPECT_EQ(string1, string2) << "Test failed. Content was not identical." << std::endl << std::endl; - return; - } - - std::cout << "OK" << std::endl << std::endl; } } // namespace test_save_load diff --git a/tests/json/test_save_load.hpp b/tests/json/test_save_load.hpp deleted file mode 100644 index a8829fd1..00000000 --- a/tests/json/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_set.cpp b/tests/json/test_set.cpp index 19600193..6456cb0a 100644 --- a/tests/json/test_set.cpp +++ b/tests/json/test_set.cpp @@ -1,5 +1,3 @@ -#include "test_set.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/json/test_set.hpp b/tests/json/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/json/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_shared_ptr.cpp b/tests/json/test_shared_ptr.cpp index 71c44d18..67c9ffaf 100644 --- a/tests/json/test_shared_ptr.cpp +++ b/tests/json/test_shared_ptr.cpp @@ -6,7 +6,6 @@ #include #include -#include "test_unique_ptr.hpp" #include "write_and_read.hpp" namespace test_shared_ptr { @@ -17,9 +16,7 @@ struct Person { std::shared_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_shared_ptr) { auto children = std::make_shared>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); diff --git a/tests/json/test_shared_ptr.hpp b/tests/json/test_shared_ptr.hpp deleted file mode 100644 index ac05afcf..00000000 --- a/tests/json/test_shared_ptr.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_shared_ptr { -void test(); -} - diff --git a/tests/json/test_size.cpp b/tests/json/test_size.cpp index f4935f9d..a66163b6 100644 --- a/tests/json/test_size.cpp +++ b/tests/json/test_size.cpp @@ -1,5 +1,3 @@ -#include "test_size.hpp" - #include #include #include @@ -20,9 +18,7 @@ struct Person { children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/json/test_size.hpp b/tests/json/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/json/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_std_ref.cpp b/tests/json/test_std_ref.cpp index d1e1d5d8..e2cd1605 100644 --- a/tests/json/test_std_ref.cpp +++ b/tests/json/test_std_ref.cpp @@ -1,5 +1,3 @@ -#include "test_std_ref.hpp" - #include #include #include @@ -7,29 +5,24 @@ #include #include +#include + namespace test_std_ref { struct StdRefStruct { std::reference_wrapper a; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_std_ref) { int i = 10; StdRefStruct struct_ = {.a = std::ref(i)}; const auto json_string = rfl::json::write(struct_); const std::string& expected = R"({"a":10})"; - if (json_string != expected) { - std::cout << "Test failed on write. Expected:" << std::endl + EXPECT_EQ(json_string, expected) << "Test failed on write. Expected:" << std::endl << expected << std::endl << "Got: " << std::endl << json_string << std::endl << std::endl; - return; - } - std::cout << "OK" << std::endl << std::endl; } - } // namespace test_std_ref diff --git a/tests/json/test_std_ref.hpp b/tests/json/test_std_ref.hpp deleted file mode 100644 index b62bb265..00000000 --- a/tests/json/test_std_ref.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_std_ref { -void test(); -} diff --git a/tests/json/test_string_map.cpp b/tests/json/test_string_map.cpp index 41dc61d9..3b4f9cf8 100644 --- a/tests/json/test_string_map.cpp +++ b/tests/json/test_string_map.cpp @@ -1,5 +1,3 @@ -#include "test_string_map.hpp" - #include #include #include @@ -11,9 +9,7 @@ #include "write_and_read.hpp" namespace test_string_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/json/test_string_map.hpp b/tests/json/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/json/test_string_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_string_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_string_unordered_map.cpp b/tests/json/test_string_unordered_map.cpp index 69a72829..bda628b9 100644 --- a/tests/json/test_string_unordered_map.cpp +++ b/tests/json/test_string_unordered_map.cpp @@ -1,5 +1,3 @@ -#include "test_string_unordered_map.hpp" - #include #include #include @@ -11,9 +9,7 @@ #include "write_and_read.hpp" namespace test_string_unordered_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_string_unordered_map) { using Map = std::unordered_map>; Map homer; homer.insert( @@ -25,6 +21,6 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(true); } } // namespace test_string_unordered_map diff --git a/tests/json/test_string_unordered_map.hpp b/tests/json/test_string_unordered_map.hpp deleted file mode 100644 index 268057a3..00000000 --- a/tests/json/test_string_unordered_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_string_unordered_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_tagged_union.cpp b/tests/json/test_tagged_union.cpp index 2727e443..b393c09f 100644 --- a/tests/json/test_tagged_union.cpp +++ b/tests/json/test_tagged_union.cpp @@ -1,5 +1,3 @@ -#include "test_tagged_union.hpp" - #include #include #include @@ -27,9 +25,7 @@ struct Square { using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r, R"({"shape":"Rectangle","height":10.0,"width":5.0})"); diff --git a/tests/json/test_tagged_union.hpp b/tests/json/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/json/test_tagged_union.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_tagged_union{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_tagged_union2.cpp b/tests/json/test_tagged_union2.cpp index 0fa84d9f..5b70e6f8 100644 --- a/tests/json/test_tagged_union2.cpp +++ b/tests/json/test_tagged_union2.cpp @@ -1,5 +1,3 @@ -#include "test_tagged_union2.hpp" - #include #include #include @@ -30,9 +28,7 @@ struct Square { using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_tagged_union2) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r, R"({"shape":"rectangle","height":10.0,"width":5.0})"); diff --git a/tests/json/test_tagged_union2.hpp b/tests/json/test_tagged_union2.hpp deleted file mode 100644 index 05bce109..00000000 --- a/tests/json/test_tagged_union2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_tagged_union2{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_tagged_union3.cpp b/tests/json/test_tagged_union3.cpp index 82b14a04..29c05870 100644 --- a/tests/json/test_tagged_union3.cpp +++ b/tests/json/test_tagged_union3.cpp @@ -1,5 +1,3 @@ -#include "test_tagged_union3.hpp" - #include #include #include @@ -32,9 +30,7 @@ struct Empty {}; using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle, Empty>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_tagged_union3) { const Shapes r = Rectangle{ .shape = rfl::Literal<"rectangle", "Rectangle", "rect">::make<"rect">(), .height = 10, diff --git a/tests/json/test_tagged_union3.hpp b/tests/json/test_tagged_union3.hpp deleted file mode 100644 index c40beebf..00000000 --- a/tests/json/test_tagged_union3.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_tagged_union3 { -void test(); -} - diff --git a/tests/json/test_timestamp.cpp b/tests/json/test_timestamp.cpp index 1adfb911..36fec8a4 100644 --- a/tests/json/test_timestamp.cpp +++ b/tests/json/test_timestamp.cpp @@ -1,5 +1,3 @@ -#include "test_timestamp.hpp" - #include #include #include @@ -20,15 +18,10 @@ struct Person { TS birthday; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_timestamp) { const auto result = TS::from_string("nonsense"); - if (result) { - std::cout << "Failed: Expected an error, but got none." << std::endl; - return; - } + ASSERT_TRUE(!result && true); const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19"}; diff --git a/tests/json/test_timestamp.hpp b/tests/json/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/json/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_transform.cpp b/tests/json/test_transform.cpp index 9c70c48f..fe41f717 100644 --- a/tests/json/test_transform.cpp +++ b/tests/json/test_transform.cpp @@ -7,7 +7,6 @@ #include #include -#include "test_replace.hpp" #include "write_and_read.hpp" namespace test_transform { @@ -18,9 +17,7 @@ struct Person { int age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_transform) { const auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}; diff --git a/tests/json/test_transform.hpp b/tests/json/test_transform.hpp deleted file mode 100644 index c02101da..00000000 --- a/tests/json/test_transform.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_transform { -void test(); -} - diff --git a/tests/json/test_unique_ptr.cpp b/tests/json/test_unique_ptr.cpp index e354862d..131eb69a 100644 --- a/tests/json/test_unique_ptr.cpp +++ b/tests/json/test_unique_ptr.cpp @@ -1,5 +1,3 @@ -#include "test_unique_ptr.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unique_ptr) { auto children = std::make_unique>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); diff --git a/tests/json/test_unique_ptr.hpp b/tests/json/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/json/test_unique_ptr.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unique_ptr{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_unique_ptr2.cpp b/tests/json/test_unique_ptr2.cpp index 4f62b94e..45c23d11 100644 --- a/tests/json/test_unique_ptr2.cpp +++ b/tests/json/test_unique_ptr2.cpp @@ -1,5 +1,3 @@ -#include "test_unique_ptr2.hpp" - #include #include #include @@ -30,9 +28,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/json/test_unique_ptr2.hpp b/tests/json/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/json/test_unique_ptr2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unique_ptr2{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_unnamed_namespace.cpp b/tests/json/test_unnamed_namespace.cpp index 9347925f..01070922 100644 --- a/tests/json/test_unnamed_namespace.cpp +++ b/tests/json/test_unnamed_namespace.cpp @@ -1,6 +1,3 @@ - -#include "test_unnamed_namespace.hpp" - #include #include #include @@ -28,9 +25,7 @@ struct Person { } // namespace -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unnamed_namespace) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/json/test_unnamed_namespace.hpp b/tests/json/test_unnamed_namespace.hpp deleted file mode 100644 index 8f64abd1..00000000 --- a/tests/json/test_unnamed_namespace.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unnamed_namespace { -void test(); -} - diff --git a/tests/json/test_unordered_map.cpp b/tests/json/test_unordered_map.cpp index 8876dce8..2be519d0 100644 --- a/tests/json/test_unordered_map.cpp +++ b/tests/json/test_unordered_map.cpp @@ -1,5 +1,3 @@ -#include "test_unordered_map.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unordered_map) { auto children = std::make_unique>(); children->insert(std::make_pair(1, Person{.first_name = "Bart"})); children->insert(std::make_pair(2, Person{.first_name = "Lisa"})); @@ -32,6 +28,7 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + + EXPECT_TRUE(true); } } // namespace test_unordered_map diff --git a/tests/json/test_unordered_map.hpp b/tests/json/test_unordered_map.hpp deleted file mode 100644 index 9b059a96..00000000 --- a/tests/json/test_unordered_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unordered_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_unordered_multimap.cpp b/tests/json/test_unordered_multimap.cpp index b9020abe..44e564aa 100644 --- a/tests/json/test_unordered_multimap.cpp +++ b/tests/json/test_unordered_multimap.cpp @@ -1,5 +1,3 @@ -#include "test_unordered_multimap.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unordered_multimap) { auto children = std::make_unique>(); children->insert(std::make_pair(1, Person{.first_name = "Bart"})); children->insert(std::make_pair(2, Person{.first_name = "Lisa"})); @@ -32,6 +28,6 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(true); } } // namespace test_unordered_multimap diff --git a/tests/json/test_unordered_multimap.hpp b/tests/json/test_unordered_multimap.hpp deleted file mode 100644 index 0f36f705..00000000 --- a/tests/json/test_unordered_multimap.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unordered_multimap{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_unordered_multiset.cpp b/tests/json/test_unordered_multiset.cpp index 8cf957d7..310115ad 100644 --- a/tests/json/test_unordered_multiset.cpp +++ b/tests/json/test_unordered_multiset.cpp @@ -1,5 +1,3 @@ -#include "test_unordered_multiset.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unordered_multiset) { auto children = std::make_unique>( std::unordered_multiset({"Bart", "Lisa", "Maggie"})); @@ -30,6 +26,6 @@ void test() { // this compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(homer2 && true); } } // namespace test_unordered_multiset diff --git a/tests/json/test_unordered_multiset.hpp b/tests/json/test_unordered_multiset.hpp deleted file mode 100644 index 491ff7ba..00000000 --- a/tests/json/test_unordered_multiset.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unordered_multiset{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_unordered_set.cpp b/tests/json/test_unordered_set.cpp index 0bfe06c5..ad229fda 100644 --- a/tests/json/test_unordered_set.cpp +++ b/tests/json/test_unordered_set.cpp @@ -1,5 +1,3 @@ -#include "test_unordered_set.hpp" - #include #include #include @@ -17,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_unordered_set) { auto children = std::make_unique>( std::unordered_set({"Bart", "Lisa", "Maggie"})); @@ -30,6 +26,6 @@ void test() { // compiles. const auto json_string = rfl::json::write(homer); const auto homer2 = rfl::json::read(json_string); - std::cout << "OK" << std::endl << std::endl; + EXPECT_TRUE(homer2 && true); } } // namespace test_unordered_set diff --git a/tests/json/test_unordered_set.hpp b/tests/json/test_unordered_set.hpp deleted file mode 100644 index be2b257f..00000000 --- a/tests/json/test_unordered_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_unordered_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_variant.cpp b/tests/json/test_variant.cpp index 18d6a056..3a574d58 100644 --- a/tests/json/test_variant.cpp +++ b/tests/json/test_variant.cpp @@ -1,5 +1,3 @@ -#include "test_variant.hpp" - #include #include #include @@ -27,9 +25,7 @@ struct Square { using Shapes = std::variant>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r, R"({"height":10.0,"width":5.0})"); diff --git a/tests/json/test_variant.hpp b/tests/json/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/json/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/json/test_view.cpp b/tests/json/test_view.cpp index f4b4b042..3e732951 100644 --- a/tests/json/test_view.cpp +++ b/tests/json/test_view.cpp @@ -7,8 +7,6 @@ #include #include -#include "rfl/internal/num_fields.hpp" -#include "test_replace.hpp" #include "write_and_read.hpp" namespace test_view { @@ -19,9 +17,7 @@ struct Person { int age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_view) { auto lisa = Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}; const auto view = rfl::to_view(lisa); diff --git a/tests/json/test_view.hpp b/tests/json/test_view.hpp deleted file mode 100644 index 89812d89..00000000 --- a/tests/json/test_view.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_view { -void test(); -} - diff --git a/tests/json/test_wstring.cpp b/tests/json/test_wstring.cpp index c6db773a..f00e3e5b 100644 --- a/tests/json/test_wstring.cpp +++ b/tests/json/test_wstring.cpp @@ -1,5 +1,3 @@ -#include "test_wstring.hpp" - #include #include #include @@ -11,9 +9,7 @@ #include "write_and_read.hpp" namespace test_wstring { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(json, test_wstring) { std::map homer; homer.insert(std::make_pair("firstName", L"Homer")); diff --git a/tests/json/test_wstring.hpp b/tests/json/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/json/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/json/tests.cpp b/tests/json/tests.cpp deleted file mode 100644 index fd415c17..00000000 --- a/tests/json/tests.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "test_all_of.hpp" -#include "test_alphanumeric_map.hpp" -#include "test_alphanumeric_unordered_map.hpp" -#include "test_and_then.hpp" -#include "test_anonymous_fields.hpp" -#include "test_any_of.hpp" -#include "test_apply.hpp" -#include "test_array.hpp" -#include "test_as.hpp" -#include "test_as2.hpp" -#include "test_as_flatten.hpp" -#include "test_box.hpp" -#include "test_box2.hpp" -#include "test_c_array_class1.hpp" -#include "test_c_array_class2.hpp" -#include "test_c_array_class3.hpp" -#include "test_c_array_class4.hpp" -#include "test_c_array_class5.hpp" -#include "test_const_fields.hpp" -#include "test_custom_class1.hpp" -#include "test_custom_class2.hpp" -#include "test_custom_class3.hpp" -#include "test_custom_class4.hpp" -#include "test_custom_constructor.hpp" -#include "test_default_values.hpp" -#include "test_deque.hpp" -#include "test_email.hpp" -#include "test_empty_object.hpp" -#include "test_enum1.hpp" -#include "test_enum2.hpp" -#include "test_enum3.hpp" -#include "test_enum4.hpp" -#include "test_enum5.hpp" -#include "test_enum6.hpp" -#include "test_enum7.hpp" -#include "test_error_messages.hpp" -#include "test_field_variant.hpp" -#include "test_flag_enum1.hpp" -#include "test_flag_enum2.hpp" -#include "test_flag_enum_with_int.hpp" -#include "test_flatten.hpp" -#include "test_flatten_anonymous.hpp" -#include "test_forward_list.hpp" -#include "test_inside_function.hpp" -#include "test_json_schema.hpp" -#include "test_list.hpp" -#include "test_literal.hpp" -#include "test_literal_map.hpp" -#include "test_literal_unordered_map.hpp" -#include "test_map.hpp" -#include "test_map_with_key_validation.hpp" -#include "test_meta_fields.hpp" -#include "test_monster_example.hpp" -#include "test_multimap.hpp" -#include "test_multiset.hpp" -#include "test_one_of.hpp" -#include "test_optional_fields.hpp" -#include "test_readme_example.hpp" -#include "test_ref.hpp" -#include "test_replace.hpp" -#include "test_replace2.hpp" -#include "test_replace_flatten.hpp" -#include "test_replace_flatten2.hpp" -#include "test_replace_with_other_struct.hpp" -#include "test_replace_with_other_struct2.hpp" -#include "test_result.hpp" -#include "test_save_load.hpp" -#include "test_set.hpp" -#include "test_shared_ptr.hpp" -#include "test_size.hpp" -#include "test_std_ref.hpp" -#include "test_string_map.hpp" -#include "test_string_unordered_map.hpp" -#include "test_tagged_union.hpp" -#include "test_tagged_union2.hpp" -#include "test_tagged_union3.hpp" -#include "test_timestamp.hpp" -#include "test_transform.hpp" -#include "test_unique_ptr.hpp" -#include "test_unique_ptr2.hpp" -#include "test_unnamed_namespace.hpp" -#include "test_unordered_map.hpp" -#include "test_unordered_multimap.hpp" -#include "test_unordered_multiset.hpp" -#include "test_unordered_set.hpp" -#include "test_variant.hpp" -#include "test_view.hpp" -#include "test_wstring.hpp" -#include "test_inheritance.hpp" -#include "test_inheritance2.hpp" - -int main() { - test_readme_example::test(); - test_default_values::test(); - test_optional_fields::test(); - test_unique_ptr::test(); - test_unique_ptr2::test(); - test_shared_ptr::test(); - test_literal::test(); - test_variant::test(); - test_tagged_union::test(); - test_tagged_union2::test(); - test_tagged_union3::test(); - test_field_variant::test(); - test_ref::test(); - test_box::test(); - test_box2::test(); - test_array::test(); - test_timestamp::test(); - test_flatten::test(); - test_flatten_anonymous::test(); - test_deque::test(); - test_forward_list::test(); - test_list::test(); - test_map::test(); - test_map_with_key_validation::test(); - test_unordered_map::test(); - test_set::test(); - test_unordered_set::test(); - test_multimap::test(); - test_unordered_multimap::test(); - test_multiset::test(); - test_unordered_multiset::test(); - test_std_ref::test(); - test_string_map::test(); - test_string_unordered_map::test(); - test_alphanumeric_map::test(); - test_alphanumeric_unordered_map::test(); - test_literal_map::test(); - test_literal_unordered_map::test(); - test_error_messages::test(); - test_result::test(); - test_anonymous_fields::test(); - test_monster_example::test(); - test_unnamed_namespace::test(); - test_inside_function::test(); - test_const_fields::test(); - test_empty_object::test(); - - test_enum1::test(); - test_enum2::test(); - test_enum3::test(); - test_enum4::test(); - test_enum5::test(); - test_enum6::test(); - test_enum7::test(); - test_flag_enum1::test(); - test_flag_enum2::test(); - test_flag_enum_with_int::test(); - - test_custom_class1::test(); - test_custom_class2::test(); - test_custom_class3::test(); - test_custom_class4::test(); - - test_c_array_class1::test(); - test_c_array_class2::test(); - test_c_array_class3::test(); - test_c_array_class4::test(); - test_c_array_class5::test(); - - test_replace::test(); - test_replace2::test(); - test_replace_flatten::test(); - test_replace_flatten2::test(); - test_replace_with_other_struct::test(); - test_replace_with_other_struct2::test(); - test_as::test(); - test_as2::test(); - test_as_flatten::test(); - - test_view::test(); - test_apply::test(); - test_transform::test(); - test_and_then::test(); - - test_custom_constructor::test(); - - test_all_of::test(); - test_any_of::test(); - test_one_of::test(); - test_email::test(); - test_size::test(); - - test_save_load::test(); - - test_meta_fields::test(); - - test_wstring::test(); - test_json_schema::test(); - - test_inheritance::test(); - test_inheritance2::test(); - - return 0; -} diff --git a/tests/json/write_and_read.hpp b/tests/json/write_and_read.hpp index 7aae95f2..5f2c9e79 100644 --- a/tests/json/write_and_read.hpp +++ b/tests/json/write_and_read.hpp @@ -1,37 +1,31 @@ #ifndef WRITE_AND_READ_ #define WRITE_AND_READ_ +#include + #include #include #include template void write_and_read(const T& _struct, const std::string& _expected) { - const auto json_string1 = rfl::json::write(_struct); - if (json_string1 != _expected) { - std::cout << "Test failed on write. Expected:" << std::endl - << _expected << std::endl - << "Got: " << std::endl - << json_string1 << std::endl - << std::endl; - return; - } - const auto res = rfl::json::read(json_string1); - if (!res) { - std::cout << "Test failed on read. Error: " - << res.error().value().what() << std::endl; - return; - } - const auto json_string2 = rfl::json::write(res.value()); - if (json_string2 != _expected) { - std::cout << "Test failed on read. Expected:" << std::endl - << _expected << std::endl - << "Got: " << std::endl - << json_string2 << std::endl - << std::endl; - return; - } - std::cout << "OK" << std::endl << std::endl; + const auto json_string1 = rfl::json::write(_struct); + EXPECT_EQ(json_string1, _expected) + << "Test failed on write. Expected:" << std::endl + << _expected << std::endl + << "Got: " << std::endl + << json_string1 << std::endl + << std::endl; + const auto res = rfl::json::read(json_string1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto json_string2 = rfl::json::write(res.value()); + EXPECT_EQ(json_string2, _expected) + << "Test failed on read. Expected:" << std::endl + << _expected << std::endl + << "Got: " << std::endl + << json_string2 << std::endl + << std::endl; } #endif