From 7aa7b0f60c982f30faa875973810662464ee01f2 Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Mon, 22 Apr 2024 19:07:58 +0200 Subject: [PATCH] Using GTest for testing msgpack --- CMakeLists.txt | 1 - tests/msgpack/CMakeLists.txt | 16 ++++- tests/msgpack/test_array.cpp | 6 +- tests/msgpack/test_array.hpp | 4 -- tests/msgpack/test_box.cpp | 6 +- tests/msgpack/test_box.hpp | 4 -- tests/msgpack/test_custom_class1.cpp | 6 +- tests/msgpack/test_custom_class1.hpp | 4 -- tests/msgpack/test_custom_class3.cpp | 6 +- tests/msgpack/test_custom_class3.hpp | 4 -- tests/msgpack/test_custom_class4.cpp | 6 +- tests/msgpack/test_custom_class4.hpp | 4 -- tests/msgpack/test_default_values.cpp | 6 +- tests/msgpack/test_default_values.hpp | 4 -- tests/msgpack/test_deque.cpp | 6 +- tests/msgpack/test_deque.hpp | 4 -- tests/msgpack/test_enum.cpp | 6 +- tests/msgpack/test_enum.hpp | 4 -- tests/msgpack/test_field_variant.cpp | 6 +- tests/msgpack/test_field_variant.hpp | 4 -- tests/msgpack/test_flag_enum.cpp | 5 +- tests/msgpack/test_flag_enum.hpp | 4 -- tests/msgpack/test_flag_enum_with_int.cpp | 5 +- tests/msgpack/test_flag_enum_with_int.hpp | 4 -- tests/msgpack/test_flatten.cpp | 6 +- tests/msgpack/test_flatten.hpp | 4 -- tests/msgpack/test_flatten_anonymous.cpp | 6 +- tests/msgpack/test_flatten_anonymous.hpp | 4 -- tests/msgpack/test_forward_list.cpp | 6 +- tests/msgpack/test_forward_list.hpp | 4 -- tests/msgpack/test_literal.cpp | 6 +- tests/msgpack/test_literal.hpp | 4 -- tests/msgpack/test_literal_map.cpp | 6 +- tests/msgpack/test_literal_map.hpp | 4 -- tests/msgpack/test_map.cpp | 6 +- tests/msgpack/test_map.hpp | 4 -- .../msgpack/test_map_with_key_validation.cpp | 6 +- .../msgpack/test_map_with_key_validation.hpp | 4 -- tests/msgpack/test_monster_example.cpp | 6 +- tests/msgpack/test_monster_example.hpp | 4 -- tests/msgpack/test_readme_example.cpp | 6 +- tests/msgpack/test_readme_example.hpp | 4 -- tests/msgpack/test_readme_example2.cpp | 5 +- tests/msgpack/test_readme_example2.hpp | 4 -- tests/msgpack/test_ref.cpp | 6 +- tests/msgpack/test_ref.hpp | 4 -- tests/msgpack/test_save_load.cpp | 16 ++--- tests/msgpack/test_save_load.hpp | 4 -- tests/msgpack/test_set.cpp | 6 +- tests/msgpack/test_set.hpp | 4 -- tests/msgpack/test_size.cpp | 6 +- tests/msgpack/test_size.hpp | 4 -- tests/msgpack/test_string_map.cpp | 6 +- tests/msgpack/test_string_map.hpp | 4 -- tests/msgpack/test_tagged_union.cpp | 7 +- tests/msgpack/test_tagged_union.hpp | 4 -- tests/msgpack/test_timestamp.cpp | 6 +- tests/msgpack/test_timestamp.hpp | 4 -- tests/msgpack/test_unique_ptr.cpp | 6 +- tests/msgpack/test_unique_ptr.hpp | 4 -- tests/msgpack/test_unique_ptr2.cpp | 6 +- tests/msgpack/test_unique_ptr2.hpp | 4 -- tests/msgpack/test_variant.cpp | 6 +- tests/msgpack/test_variant.hpp | 4 -- tests/msgpack/test_wstring.cpp | 12 ++-- tests/msgpack/test_wstring.hpp | 3 - tests/msgpack/tests.cpp | 67 ------------------- tests/msgpack/write_and_read.hpp | 35 +++------- tests/xml/get_pugixml.sh | 3 - 69 files changed, 59 insertions(+), 396 deletions(-) delete mode 100644 tests/msgpack/test_array.hpp delete mode 100644 tests/msgpack/test_box.hpp delete mode 100644 tests/msgpack/test_custom_class1.hpp delete mode 100644 tests/msgpack/test_custom_class3.hpp delete mode 100644 tests/msgpack/test_custom_class4.hpp delete mode 100644 tests/msgpack/test_default_values.hpp delete mode 100644 tests/msgpack/test_deque.hpp delete mode 100644 tests/msgpack/test_enum.hpp delete mode 100644 tests/msgpack/test_field_variant.hpp delete mode 100644 tests/msgpack/test_flag_enum.hpp delete mode 100644 tests/msgpack/test_flag_enum_with_int.hpp delete mode 100644 tests/msgpack/test_flatten.hpp delete mode 100644 tests/msgpack/test_flatten_anonymous.hpp delete mode 100644 tests/msgpack/test_forward_list.hpp delete mode 100644 tests/msgpack/test_literal.hpp delete mode 100644 tests/msgpack/test_literal_map.hpp delete mode 100644 tests/msgpack/test_map.hpp delete mode 100644 tests/msgpack/test_map_with_key_validation.hpp delete mode 100644 tests/msgpack/test_monster_example.hpp delete mode 100644 tests/msgpack/test_readme_example.hpp delete mode 100644 tests/msgpack/test_readme_example2.hpp delete mode 100644 tests/msgpack/test_ref.hpp delete mode 100644 tests/msgpack/test_save_load.hpp delete mode 100644 tests/msgpack/test_set.hpp delete mode 100644 tests/msgpack/test_size.hpp delete mode 100644 tests/msgpack/test_string_map.hpp delete mode 100644 tests/msgpack/test_tagged_union.hpp delete mode 100644 tests/msgpack/test_timestamp.hpp delete mode 100644 tests/msgpack/test_unique_ptr.hpp delete mode 100644 tests/msgpack/test_unique_ptr2.hpp delete mode 100644 tests/msgpack/test_variant.hpp delete mode 100644 tests/msgpack/test_wstring.hpp delete mode 100644 tests/msgpack/tests.cpp delete mode 100755 tests/xml/get_pugixml.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 137fb992..cc26bcb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,6 @@ if (REFLECTCPP_BUILD_TESTS) add_subdirectory(tests) endif () - include(GNUInstallDirs) include(CMakePackageConfigHelpers) diff --git a/tests/msgpack/CMakeLists.txt b/tests/msgpack/CMakeLists.txt index 222ea521..b49c98e1 100644 --- a/tests/msgpack/CMakeLists.txt +++ b/tests/msgpack/CMakeLists.txt @@ -1,8 +1,18 @@ project(reflect-cpp-msgpack-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-msgpack-tests ${SOURCES}) +add_executable( + reflect-cpp-msgpack-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) target_include_directories(reflect-cpp-msgpack-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") -target_link_libraries(reflect-cpp-msgpack-tests PRIVATE reflectcpp) + +target_link_libraries( + reflect-cpp-msgpack-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/msgpack/test_array.cpp b/tests/msgpack/test_array.cpp index 75f670d2..a6943a79 100644 --- a/tests/msgpack/test_array.cpp +++ b/tests/msgpack/test_array.cpp @@ -1,5 +1,3 @@ -#include "test_array.hpp" - #include #include #include @@ -21,9 +19,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/msgpack/test_array.hpp b/tests/msgpack/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/msgpack/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_box.cpp b/tests/msgpack/test_box.cpp index fdb3516a..9685ffd1 100644 --- a/tests/msgpack/test_box.cpp +++ b/tests/msgpack/test_box.cpp @@ -1,5 +1,3 @@ -#include "test_box.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/msgpack/test_box.hpp b/tests/msgpack/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/msgpack/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_custom_class1.cpp b/tests/msgpack/test_custom_class1.cpp index fe8d0ea0..b61d122c 100644 --- a/tests/msgpack/test_custom_class1.cpp +++ b/tests/msgpack/test_custom_class1.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class1.hpp" - #include #include #include @@ -31,9 +29,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/msgpack/test_custom_class1.hpp b/tests/msgpack/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/msgpack/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/msgpack/test_custom_class3.cpp b/tests/msgpack/test_custom_class3.cpp index 598364b1..7ef3a094 100644 --- a/tests/msgpack/test_custom_class3.cpp +++ b/tests/msgpack/test_custom_class3.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class3.hpp" - #include #include #include @@ -56,9 +54,7 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/msgpack/test_custom_class3.hpp b/tests/msgpack/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/msgpack/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/msgpack/test_custom_class4.cpp b/tests/msgpack/test_custom_class4.cpp index 2b3b3bac..46906e0f 100644 --- a/tests/msgpack/test_custom_class4.cpp +++ b/tests/msgpack/test_custom_class4.cpp @@ -1,5 +1,3 @@ -#include "test_custom_class4.hpp" - #include #include #include @@ -57,9 +55,7 @@ struct Parser namespace test_custom_class4 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/msgpack/test_custom_class4.hpp b/tests/msgpack/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/msgpack/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/msgpack/test_default_values.cpp b/tests/msgpack/test_default_values.cpp index f6af2352..078e53a0 100644 --- a/tests/msgpack/test_default_values.cpp +++ b/tests/msgpack/test_default_values.cpp @@ -1,5 +1,3 @@ -#include "test_default_values.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(msgpack, 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/msgpack/test_default_values.hpp b/tests/msgpack/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/msgpack/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/msgpack/test_deque.cpp b/tests/msgpack/test_deque.cpp index 6dfa5803..d21c3e5f 100644 --- a/tests/msgpack/test_deque.cpp +++ b/tests/msgpack/test_deque.cpp @@ -1,5 +1,3 @@ -#include "test_deque.hpp" - #include #include #include @@ -16,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_default_values) { auto children = std::make_unique>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); diff --git a/tests/msgpack/test_deque.hpp b/tests/msgpack/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/msgpack/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_enum.cpp b/tests/msgpack/test_enum.cpp index d4d56a8b..c5482dfa 100644 --- a/tests/msgpack/test_enum.cpp +++ b/tests/msgpack/test_enum.cpp @@ -1,5 +1,3 @@ -#include "test_enum.hpp" - #include #include #include @@ -18,9 +16,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/msgpack/test_enum.hpp b/tests/msgpack/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/msgpack/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/msgpack/test_field_variant.cpp b/tests/msgpack/test_field_variant.cpp index 8b17665f..caf7295c 100644 --- a/tests/msgpack/test_field_variant.cpp +++ b/tests/msgpack/test_field_variant.cpp @@ -1,5 +1,3 @@ -#include "test_field_variant.hpp" - #include #include #include @@ -28,9 +26,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(msgpack, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/msgpack/test_field_variant.hpp b/tests/msgpack/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/msgpack/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/msgpack/test_flag_enum.cpp b/tests/msgpack/test_flag_enum.cpp index 1d3f76af..775a10c7 100644 --- a/tests/msgpack/test_flag_enum.cpp +++ b/tests/msgpack/test_flag_enum.cpp @@ -5,7 +5,6 @@ #include #include -#include "test_enum.hpp" #include "write_and_read.hpp" namespace test_flag_enum { @@ -27,9 +26,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/msgpack/test_flag_enum.hpp b/tests/msgpack/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/msgpack/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/msgpack/test_flag_enum_with_int.cpp b/tests/msgpack/test_flag_enum_with_int.cpp index 4c7deefe..5ae88fa9 100644 --- a/tests/msgpack/test_flag_enum_with_int.cpp +++ b/tests/msgpack/test_flag_enum_with_int.cpp @@ -5,7 +5,6 @@ #include #include -#include "test_enum.hpp" #include "write_and_read.hpp" namespace test_flag_enum_with_int { @@ -27,9 +26,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/msgpack/test_flag_enum_with_int.hpp b/tests/msgpack/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/msgpack/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/msgpack/test_flatten.cpp b/tests/msgpack/test_flatten.cpp index c7f1d9be..972a67e4 100644 --- a/tests/msgpack/test_flatten.cpp +++ b/tests/msgpack/test_flatten.cpp @@ -1,5 +1,3 @@ -#include "test_flatten.hpp" - #include #include #include @@ -23,9 +21,7 @@ struct Employee { rfl::Field<"salary", float> salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/msgpack/test_flatten.hpp b/tests/msgpack/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/msgpack/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_flatten_anonymous.cpp b/tests/msgpack/test_flatten_anonymous.cpp index 05e61464..e4639fd6 100644 --- a/tests/msgpack/test_flatten_anonymous.cpp +++ b/tests/msgpack/test_flatten_anonymous.cpp @@ -1,5 +1,3 @@ -#include "test_flatten_anonymous.hpp" - #include #include #include @@ -23,9 +21,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/msgpack/test_flatten_anonymous.hpp b/tests/msgpack/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/msgpack/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/msgpack/test_forward_list.cpp b/tests/msgpack/test_forward_list.cpp index dd8d9e56..0c71740f 100644 --- a/tests/msgpack/test_forward_list.cpp +++ b/tests/msgpack/test_forward_list.cpp @@ -1,5 +1,3 @@ -#include "test_forward_list.hpp" - #include #include #include @@ -16,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, 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/msgpack/test_forward_list.hpp b/tests/msgpack/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/msgpack/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/msgpack/test_literal.cpp b/tests/msgpack/test_literal.cpp index 00578178..1ad7059f 100644 --- a/tests/msgpack/test_literal.cpp +++ b/tests/msgpack/test_literal.cpp @@ -1,5 +1,3 @@ -#include "test_literal.hpp" - #include #include #include @@ -20,9 +18,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/msgpack/test_literal.hpp b/tests/msgpack/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/msgpack/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_literal_map.cpp b/tests/msgpack/test_literal_map.cpp index 9bbebafb..fc0d6dd2 100644 --- a/tests/msgpack/test_literal_map.cpp +++ b/tests/msgpack/test_literal_map.cpp @@ -1,5 +1,3 @@ -#include "test_literal_map.hpp" - #include #include #include @@ -14,9 +12,7 @@ namespace test_literal_map { using FieldName = rfl::Literal<"firstName", "lastName">; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/msgpack/test_literal_map.hpp b/tests/msgpack/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/msgpack/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/msgpack/test_map.cpp b/tests/msgpack/test_map.cpp index e37ce564..e64c3e62 100644 --- a/tests/msgpack/test_map.cpp +++ b/tests/msgpack/test_map.cpp @@ -1,5 +1,3 @@ -#include "test_map.hpp" - #include #include #include @@ -16,9 +14,7 @@ struct Person { std::map children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_map) { auto children = std::map(); children.insert(std::make_pair("child1", Person{.first_name = "Bart"})); children.insert(std::make_pair("child2", Person{.first_name = "Lisa"})); diff --git a/tests/msgpack/test_map.hpp b/tests/msgpack/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/msgpack/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_map_with_key_validation.cpp b/tests/msgpack/test_map_with_key_validation.cpp index e758219d..04a30bdd 100644 --- a/tests/msgpack/test_map_with_key_validation.cpp +++ b/tests/msgpack/test_map_with_key_validation.cpp @@ -1,5 +1,3 @@ -#include "test_map_with_key_validation.hpp" - #include #include #include @@ -16,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/msgpack/test_map_with_key_validation.hpp b/tests/msgpack/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/msgpack/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/msgpack/test_monster_example.cpp b/tests/msgpack/test_monster_example.cpp index 052d8390..5b424146 100644 --- a/tests/msgpack/test_monster_example.cpp +++ b/tests/msgpack/test_monster_example.cpp @@ -1,5 +1,3 @@ -#include "test_monster_example.hpp" - #include #include #include @@ -38,9 +36,7 @@ struct Monster { std::vector path; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/msgpack/test_monster_example.hpp b/tests/msgpack/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/msgpack/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/msgpack/test_readme_example.cpp b/tests/msgpack/test_readme_example.cpp index 4e6f8ee0..d48b38ed 100644 --- a/tests/msgpack/test_readme_example.cpp +++ b/tests/msgpack/test_readme_example.cpp @@ -1,5 +1,3 @@ -#include "test_readme_example.hpp" - #include #include #include @@ -22,9 +20,7 @@ struct Person { std::vector child; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/msgpack/test_readme_example.hpp b/tests/msgpack/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/msgpack/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/msgpack/test_readme_example2.cpp b/tests/msgpack/test_readme_example2.cpp index a2d212a4..a490f33c 100644 --- a/tests/msgpack/test_readme_example2.cpp +++ b/tests/msgpack/test_readme_example2.cpp @@ -4,7 +4,6 @@ #include #include -#include "test_readme_example.hpp" #include "write_and_read.hpp" namespace test_readme_example2 { @@ -15,9 +14,7 @@ struct Person { int age; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_readme_example2) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/msgpack/test_readme_example2.hpp b/tests/msgpack/test_readme_example2.hpp deleted file mode 100644 index 5c6b011c..00000000 --- a/tests/msgpack/test_readme_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example2 { -void test(); -} - diff --git a/tests/msgpack/test_ref.cpp b/tests/msgpack/test_ref.cpp index 32a32e6c..a2121d6e 100644 --- a/tests/msgpack/test_ref.cpp +++ b/tests/msgpack/test_ref.cpp @@ -1,5 +1,3 @@ -#include "test_ref.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/msgpack/test_ref.hpp b/tests/msgpack/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/msgpack/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_save_load.cpp b/tests/msgpack/test_save_load.cpp index 3e8c4703..d6d64e39 100644 --- a/tests/msgpack/test_save_load.cpp +++ b/tests/msgpack/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(msgpack, test_save_load) { const auto bart = Person{.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19", @@ -59,12 +57,6 @@ void test() { const auto string1 = rfl::msgpack::write(homer1); const auto string2 = rfl::msgpack::write(homer2); - if (string1 != string2) { - std::cout << "Test failed. Content was not identical." << std::endl - << std::endl; - return; - } - - std::cout << "OK" << std::endl << std::endl; + EXPECT_EQ(string1, string2); } } // namespace test_save_load diff --git a/tests/msgpack/test_save_load.hpp b/tests/msgpack/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/msgpack/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/msgpack/test_set.cpp b/tests/msgpack/test_set.cpp index 9f2516ce..2dbd2b37 100644 --- a/tests/msgpack/test_set.cpp +++ b/tests/msgpack/test_set.cpp @@ -1,5 +1,3 @@ -#include "test_set.hpp" - #include #include #include @@ -16,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/msgpack/test_set.hpp b/tests/msgpack/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/msgpack/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_size.cpp b/tests/msgpack/test_size.cpp index c37b9bd8..38301fe0 100644 --- a/tests/msgpack/test_size.cpp +++ b/tests/msgpack/test_size.cpp @@ -1,5 +1,3 @@ -#include "test_size.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Person { children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/msgpack/test_size.hpp b/tests/msgpack/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/msgpack/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_string_map.cpp b/tests/msgpack/test_string_map.cpp index cb4fb903..ed8af4d5 100644 --- a/tests/msgpack/test_string_map.cpp +++ b/tests/msgpack/test_string_map.cpp @@ -1,5 +1,3 @@ -#include "test_string_map.hpp" - #include #include #include @@ -10,9 +8,7 @@ #include "write_and_read.hpp" namespace test_string_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/msgpack/test_string_map.hpp b/tests/msgpack/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/msgpack/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/msgpack/test_tagged_union.cpp b/tests/msgpack/test_tagged_union.cpp index a9dd1abc..889f89a4 100644 --- a/tests/msgpack/test_tagged_union.cpp +++ b/tests/msgpack/test_tagged_union.cpp @@ -1,5 +1,3 @@ -#include "test_tagged_union.hpp" - #include #include #include @@ -26,11 +24,8 @@ struct Square { using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/msgpack/test_tagged_union.hpp b/tests/msgpack/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/msgpack/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/msgpack/test_timestamp.cpp b/tests/msgpack/test_timestamp.cpp index 8af261d1..6ded3cfe 100644 --- a/tests/msgpack/test_timestamp.cpp +++ b/tests/msgpack/test_timestamp.cpp @@ -1,5 +1,3 @@ -#include "test_timestamp.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Person { TS birthday; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/msgpack/test_timestamp.hpp b/tests/msgpack/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/msgpack/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_unique_ptr.cpp b/tests/msgpack/test_unique_ptr.cpp index b1833533..73732e55 100644 --- a/tests/msgpack/test_unique_ptr.cpp +++ b/tests/msgpack/test_unique_ptr.cpp @@ -1,5 +1,3 @@ -#include "test_unique_ptr.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(msgpack, 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/msgpack/test_unique_ptr.hpp b/tests/msgpack/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/msgpack/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/msgpack/test_unique_ptr2.cpp b/tests/msgpack/test_unique_ptr2.cpp index e3007267..35d374c6 100644 --- a/tests/msgpack/test_unique_ptr2.cpp +++ b/tests/msgpack/test_unique_ptr2.cpp @@ -1,5 +1,3 @@ -#include "test_unique_ptr2.hpp" - #include #include #include @@ -29,9 +27,7 @@ struct DecisionTree { rfl::Field<"leafOrNode", LeafOrNode> leaf_or_node; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/msgpack/test_unique_ptr2.hpp b/tests/msgpack/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/msgpack/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/msgpack/test_variant.cpp b/tests/msgpack/test_variant.cpp index cc3d6cbe..fc038fca 100644 --- a/tests/msgpack/test_variant.cpp +++ b/tests/msgpack/test_variant.cpp @@ -1,5 +1,3 @@ -#include "test_variant.hpp" - #include #include #include @@ -26,9 +24,7 @@ struct Square { using Shapes = std::variant>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(msgpack, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/msgpack/test_variant.hpp b/tests/msgpack/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/msgpack/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/msgpack/test_wstring.cpp b/tests/msgpack/test_wstring.cpp index ba6202c0..3b2bb994 100644 --- a/tests/msgpack/test_wstring.cpp +++ b/tests/msgpack/test_wstring.cpp @@ -1,5 +1,3 @@ -#include "test_wstring.hpp" - #include #include #include @@ -9,17 +7,15 @@ #include "write_and_read.hpp" -struct Test { +struct TestStruct { std::string theNormalString; std::wstring theWiderString; }; namespace test_wstring { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const Test test = Test{.theNormalString = "The normal string", - .theWiderString = L"The wider string"}; +TEST(msgpack, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/msgpack/test_wstring.hpp b/tests/msgpack/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/msgpack/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/msgpack/tests.cpp b/tests/msgpack/tests.cpp deleted file mode 100644 index 8a9fe0fb..00000000 --- a/tests/msgpack/tests.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "test_array.hpp" -#include "test_box.hpp" -#include "test_custom_class1.hpp" -#include "test_custom_class3.hpp" -#include "test_custom_class4.hpp" -#include "test_default_values.hpp" -#include "test_deque.hpp" -#include "test_enum.hpp" -#include "test_field_variant.hpp" -#include "test_flag_enum.hpp" -#include "test_flag_enum_with_int.hpp" -#include "test_flatten.hpp" -#include "test_flatten_anonymous.hpp" -#include "test_forward_list.hpp" -#include "test_literal.hpp" -#include "test_literal_map.hpp" -#include "test_map.hpp" -#include "test_map_with_key_validation.hpp" -#include "test_monster_example.hpp" -#include "test_readme_example.hpp" -#include "test_readme_example2.hpp" -#include "test_ref.hpp" -#include "test_save_load.hpp" -#include "test_set.hpp" -#include "test_size.hpp" -#include "test_tagged_union.hpp" -#include "test_timestamp.hpp" -#include "test_unique_ptr.hpp" -#include "test_unique_ptr2.hpp" -#include "test_variant.hpp" -#include "test_wstring.hpp" - -int main() { - test_readme_example::test(); - test_readme_example2::test(); - test_flatten::test(); - test_flatten_anonymous::test(); - test_enum::test(); - test_flag_enum::test(); - test_flag_enum_with_int::test(); - test_map::test(); - test_map_with_key_validation::test(); - test_variant::test(); - test_field_variant::test(); - test_tagged_union::test(); - test_deque::test(); - test_forward_list::test(); - test_literal_map::test(); - test_literal::test(); - test_monster_example::test(); - test_ref::test(); - test_set::test(); - test_size::test(); - test_timestamp::test(); - test_unique_ptr::test(); - test_unique_ptr2::test(); - test_array::test(); - test_box::test(); - test_custom_class1::test(); - test_custom_class3::test(); - test_custom_class4::test(); - test_default_values::test(); - test_save_load::test(); - test_wstring::test(); - - return 0; -} diff --git a/tests/msgpack/write_and_read.hpp b/tests/msgpack/write_and_read.hpp index 9843c18f..bd1918d9 100644 --- a/tests/msgpack/write_and_read.hpp +++ b/tests/msgpack/write_and_read.hpp @@ -1,39 +1,20 @@ #ifndef WRITE_AND_READ_ #define WRITE_AND_READ_ +#include + #include #include #include template void write_and_read(const T& _struct) { - const auto bytes1 = rfl::msgpack::write(_struct); - - const auto res = rfl::msgpack::read(bytes1); - - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << std::endl; - return; - } - - const auto bytes2 = rfl::msgpack::write(res.value()); - - if (bytes1.size() != bytes2.size()) { - std::cout << "Test failed on write. Number of bytes was different." - << std::endl - << std::endl; - return; - } - - if (bytes1 != bytes2) { - std::cout << "Test failed on write. Content was not identical." << std::endl - << std::endl; - return; - } - - std::cout << "OK" << std::endl << std::endl; + const auto serialized1 = rfl::msgpack::write(_struct); + const auto res = rfl::msgpack::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::msgpack::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/xml/get_pugixml.sh b/tests/xml/get_pugixml.sh deleted file mode 100755 index 3aa890cd..00000000 --- a/tests/xml/get_pugixml.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -wget https://github.com/zeux/pugixml/releases/download/v1.14/pugixml-1.14.tar.gz -tar -xzvf pugixml-1.14.tar.gz