From 325d163196d10bb46dab7afc756d09539a8b3b39 Mon Sep 17 00:00:00 2001 From: liuzicheng1987 Date: Mon, 22 Apr 2024 23:12:35 +0200 Subject: [PATCH] Use GTest; resolves #34 (#90) --- .gitignore | 1 + CMakeLists.txt | 8 +- README.md | 17 +- tests/bson/CMakeLists.txt | 16 +- tests/bson/test_array.cpp | 8 +- tests/bson/test_array.hpp | 4 - tests/bson/test_box.cpp | 6 +- tests/bson/test_box.hpp | 4 - tests/bson/test_custom_class1.cpp | 6 +- tests/bson/test_custom_class1.hpp | 4 - tests/bson/test_custom_class3.cpp | 6 +- tests/bson/test_custom_class3.hpp | 4 - tests/bson/test_custom_class4.cpp | 6 +- tests/bson/test_custom_class4.hpp | 4 - tests/bson/test_default_values.cpp | 6 +- tests/bson/test_default_values.hpp | 4 - tests/bson/test_deque.cpp | 6 +- tests/bson/test_deque.hpp | 4 - tests/bson/test_enum.cpp | 6 +- tests/bson/test_enum.hpp | 4 - tests/bson/test_field_variant.cpp | 6 +- tests/bson/test_field_variant.hpp | 4 - tests/bson/test_flag_enum.cpp | 5 +- tests/bson/test_flag_enum.hpp | 4 - tests/bson/test_flag_enum_with_int.cpp | 5 +- tests/bson/test_flag_enum_with_int.hpp | 4 - tests/bson/test_flatten.cpp | 6 +- tests/bson/test_flatten.hpp | 4 - tests/bson/test_flatten_anonymous.cpp | 6 +- tests/bson/test_flatten_anonymous.hpp | 4 - tests/bson/test_forward_list.cpp | 6 +- tests/bson/test_forward_list.hpp | 4 - tests/bson/test_literal.cpp | 6 +- tests/bson/test_literal.hpp | 4 - tests/bson/test_literal_map.cpp | 6 +- tests/bson/test_literal_map.hpp | 4 - tests/bson/test_map.cpp | 6 +- tests/bson/test_map.hpp | 4 - tests/bson/test_map_with_key_validation.cpp | 6 +- tests/bson/test_map_with_key_validation.hpp | 4 - tests/bson/test_monster_example.cpp | 6 +- tests/bson/test_monster_example.hpp | 4 - tests/bson/test_readme_example.cpp | 6 +- tests/bson/test_readme_example.hpp | 4 - tests/bson/test_readme_example2.cpp | 5 +- tests/bson/test_readme_example2.hpp | 4 - tests/bson/test_ref.cpp | 6 +- tests/bson/test_ref.hpp | 4 - tests/bson/test_save_load.cpp | 16 +- tests/bson/test_save_load.hpp | 4 - tests/bson/test_set.cpp | 6 +- tests/bson/test_set.hpp | 4 - tests/bson/test_size.cpp | 6 +- tests/bson/test_size.hpp | 4 - tests/bson/test_string_map.cpp | 6 +- tests/bson/test_string_map.hpp | 4 - tests/bson/test_tagged_union.cpp | 7 +- tests/bson/test_tagged_union.hpp | 4 - tests/bson/test_timestamp.cpp | 6 +- tests/bson/test_timestamp.hpp | 4 - tests/bson/test_unique_ptr.cpp | 6 +- tests/bson/test_unique_ptr.hpp | 4 - tests/bson/test_unique_ptr2.cpp | 6 +- tests/bson/test_unique_ptr2.hpp | 4 - tests/bson/test_variant.cpp | 6 +- tests/bson/test_variant.hpp | 4 - tests/bson/test_wstring.cpp | 12 +- tests/bson/test_wstring.hpp | 3 - tests/bson/tests.cpp | 67 ------ tests/bson/write_and_read.hpp | 35 +--- tests/cbor/CMakeLists.txt | 17 +- tests/cbor/test_array.cpp | 6 +- tests/cbor/test_array.hpp | 4 - tests/cbor/test_box.cpp | 6 +- tests/cbor/test_box.hpp | 4 - tests/cbor/test_custom_class1.cpp | 6 +- tests/cbor/test_custom_class1.hpp | 4 - tests/cbor/test_custom_class3.cpp | 6 +- tests/cbor/test_custom_class3.hpp | 4 - tests/cbor/test_custom_class4.cpp | 6 +- tests/cbor/test_custom_class4.hpp | 4 - tests/cbor/test_default_values.cpp | 6 +- tests/cbor/test_default_values.hpp | 4 - tests/cbor/test_deque.cpp | 6 +- tests/cbor/test_deque.hpp | 4 - tests/cbor/test_enum.cpp | 6 +- tests/cbor/test_enum.hpp | 4 - tests/cbor/test_field_variant.cpp | 6 +- tests/cbor/test_field_variant.hpp | 4 - tests/cbor/test_flag_enum.cpp | 5 +- tests/cbor/test_flag_enum.hpp | 4 - tests/cbor/test_flag_enum_with_int.cpp | 5 +- tests/cbor/test_flag_enum_with_int.hpp | 4 - tests/cbor/test_flatten.cpp | 6 +- tests/cbor/test_flatten.hpp | 4 - tests/cbor/test_flatten_anonymous.cpp | 6 +- tests/cbor/test_flatten_anonymous.hpp | 4 - tests/cbor/test_forward_list.cpp | 6 +- tests/cbor/test_forward_list.hpp | 4 - tests/cbor/test_literal.cpp | 6 +- tests/cbor/test_literal.hpp | 4 - tests/cbor/test_literal_map.cpp | 6 +- tests/cbor/test_literal_map.hpp | 4 - tests/cbor/test_map.cpp | 6 +- tests/cbor/test_map.hpp | 4 - tests/cbor/test_map_with_key_validation.cpp | 6 +- tests/cbor/test_map_with_key_validation.hpp | 4 - tests/cbor/test_monster_example.cpp | 6 +- tests/cbor/test_monster_example.hpp | 4 - tests/cbor/test_readme_example.cpp | 6 +- tests/cbor/test_readme_example.hpp | 4 - tests/cbor/test_readme_example2.cpp | 5 +- tests/cbor/test_readme_example2.hpp | 4 - tests/cbor/test_ref.cpp | 6 +- tests/cbor/test_ref.hpp | 4 - tests/cbor/test_save_load.cpp | 16 +- tests/cbor/test_save_load.hpp | 4 - tests/cbor/test_set.cpp | 6 +- tests/cbor/test_set.hpp | 4 - tests/cbor/test_size.cpp | 6 +- tests/cbor/test_size.hpp | 4 - tests/cbor/test_string_map.cpp | 6 +- tests/cbor/test_string_map.hpp | 4 - tests/cbor/test_tagged_union.cpp | 7 +- tests/cbor/test_tagged_union.hpp | 4 - tests/cbor/test_timestamp.cpp | 6 +- tests/cbor/test_timestamp.hpp | 4 - tests/cbor/test_unique_ptr.cpp | 6 +- tests/cbor/test_unique_ptr.hpp | 4 - tests/cbor/test_unique_ptr2.cpp | 6 +- tests/cbor/test_unique_ptr2.hpp | 4 - tests/cbor/test_variant.cpp | 6 +- tests/cbor/test_variant.hpp | 4 - tests/cbor/test_wstring.cpp | 12 +- tests/cbor/test_wstring.hpp | 3 - tests/cbor/tests.cpp | 67 ------ tests/cbor/write_and_read.hpp | 35 +--- tests/flexbuffers/CMakeLists.txt | 19 +- tests/flexbuffers/README.md | 23 -- tests/flexbuffers/test_all_of.cpp | 34 --- tests/flexbuffers/test_all_of.hpp | 4 - tests/flexbuffers/test_anonymous_fields.cpp | 57 ----- tests/flexbuffers/test_anonymous_fields.hpp | 4 - tests/flexbuffers/test_array.cpp | 36 ++++ tests/flexbuffers/test_box.cpp | 18 +- tests/flexbuffers/test_box.hpp | 4 - tests/flexbuffers/test_custom_class1.cpp | 13 +- tests/flexbuffers/test_custom_class1.hpp | 4 - tests/flexbuffers/test_custom_class2.cpp | 69 ------ tests/flexbuffers/test_custom_class2.hpp | 4 - tests/flexbuffers/test_custom_class3.cpp | 31 ++- tests/flexbuffers/test_custom_class3.hpp | 4 - tests/flexbuffers/test_custom_class4.cpp | 64 ++++++ tests/flexbuffers/test_custom_constructor.cpp | 59 ------ tests/flexbuffers/test_custom_constructor.hpp | 4 - ...nal_fields.cpp => test_default_values.cpp} | 22 +- tests/flexbuffers/test_deque.cpp | 15 +- tests/flexbuffers/test_deque.hpp | 4 - tests/flexbuffers/test_enum.cpp | 25 +++ tests/flexbuffers/test_field_variant.cpp | 15 +- tests/flexbuffers/test_field_variant.hpp | 4 - tests/flexbuffers/test_flag_enum.cpp | 36 ++++ tests/flexbuffers/test_flag_enum_with_int.cpp | 35 ++++ tests/flexbuffers/test_flatten.cpp | 34 +++ tests/flexbuffers/test_flatten_anonymous.cpp | 8 +- tests/flexbuffers/test_flatten_anonymous.hpp | 4 - tests/flexbuffers/test_forward_list.cpp | 15 +- tests/flexbuffers/test_forward_list.hpp | 4 - tests/flexbuffers/test_list.cpp | 34 --- tests/flexbuffers/test_list.hpp | 4 - tests/flexbuffers/test_literal.cpp | 13 +- tests/flexbuffers/test_literal.hpp | 4 - tests/flexbuffers/test_literal_map.cpp | 24 +++ tests/flexbuffers/test_map.cpp | 22 +- tests/flexbuffers/test_map.hpp | 4 - .../test_map_with_key_validation.cpp | 29 +++ ..._example1.cpp => test_monster_example.cpp} | 23 +- tests/flexbuffers/test_monster_example1.hpp | 4 - tests/flexbuffers/test_monster_example2.cpp | 67 ------ tests/flexbuffers/test_monster_example2.hpp | 4 - tests/flexbuffers/test_multimap.cpp | 34 --- tests/flexbuffers/test_multimap.hpp | 4 - tests/flexbuffers/test_multiset.cpp | 32 --- tests/flexbuffers/test_multiset.hpp | 4 - tests/flexbuffers/test_optional_fields.hpp | 4 - tests/flexbuffers/test_readme_example.cpp | 65 +++--- tests/flexbuffers/test_readme_example.hpp | 4 - tests/flexbuffers/test_readme_example2.cpp | 23 ++ tests/flexbuffers/test_ref.cpp | 18 +- tests/flexbuffers/test_ref.hpp | 4 - tests/flexbuffers/test_save_load.cpp | 58 ++---- tests/flexbuffers/test_save_load.hpp | 4 - tests/flexbuffers/test_set.cpp | 14 +- tests/flexbuffers/test_set.hpp | 4 - tests/flexbuffers/test_size.cpp | 38 ++++ tests/flexbuffers/test_string_map.cpp | 7 +- tests/flexbuffers/test_string_map.hpp | 4 - .../flexbuffers/test_string_unordered_map.cpp | 30 --- .../flexbuffers/test_string_unordered_map.hpp | 4 - tests/flexbuffers/test_tagged_union.cpp | 10 +- tests/flexbuffers/test_tagged_union.hpp | 4 - tests/flexbuffers/test_timestamp.cpp | 32 +++ tests/flexbuffers/test_unique_ptr.cpp | 14 +- tests/flexbuffers/test_unique_ptr.hpp | 4 - tests/flexbuffers/test_unique_ptr2.cpp | 17 +- tests/flexbuffers/test_unique_ptr2.hpp | 4 - tests/flexbuffers/test_unordered_map.cpp | 38 ---- tests/flexbuffers/test_unordered_map.hpp | 4 - tests/flexbuffers/test_unordered_multimap.cpp | 38 ---- tests/flexbuffers/test_unordered_multimap.hpp | 4 - tests/flexbuffers/test_unordered_multiset.cpp | 36 ---- tests/flexbuffers/test_unordered_multiset.hpp | 4 - tests/flexbuffers/test_unordered_set.cpp | 36 ---- tests/flexbuffers/test_unordered_set.hpp | 4 - tests/flexbuffers/test_variant.cpp | 17 +- tests/flexbuffers/test_variant.hpp | 4 - tests/flexbuffers/test_wstring.cpp | 12 +- tests/flexbuffers/test_wstring.hpp | 3 - tests/flexbuffers/tests.cpp | 77 ------- tests/flexbuffers/write_and_read.hpp | 35 +--- tests/json/CMakeLists.txt | 15 +- tests/json/test_all_of.cpp | 6 +- tests/json/test_all_of.hpp | 4 - tests/json/test_alphanumeric_map.cpp | 6 +- tests/json/test_alphanumeric_map.hpp | 4 - .../json/test_alphanumeric_unordered_map.cpp | 7 +- .../json/test_alphanumeric_unordered_map.hpp | 4 - tests/json/test_and_then.cpp | 6 +- tests/json/test_and_then.hpp | 4 - tests/json/test_anonymous_fields.cpp | 6 +- tests/json/test_anonymous_fields.hpp | 4 - tests/json/test_any_of.cpp | 6 +- tests/json/test_any_of.hpp | 4 - tests/json/test_apply.cpp | 5 +- tests/json/test_apply.hpp | 4 - tests/json/test_array.cpp | 5 +- tests/json/test_array.hpp | 4 - tests/json/test_as.cpp | 5 +- tests/json/test_as.hpp | 4 - tests/json/test_as2.cpp | 6 +- tests/json/test_as2.hpp | 4 - tests/json/test_as_flatten.cpp | 6 +- tests/json/test_as_flatten.hpp | 4 - tests/json/test_box.cpp | 6 +- tests/json/test_box.hpp | 4 - tests/json/test_box2.cpp | 15 +- tests/json/test_box2.hpp | 4 - tests/json/test_c_array_class1.cpp | 6 +- tests/json/test_c_array_class1.hpp | 5 - tests/json/test_c_array_class2.cpp | 11 +- tests/json/test_c_array_class2.hpp | 5 - tests/json/test_c_array_class3.cpp | 10 +- tests/json/test_c_array_class3.hpp | 5 - tests/json/test_c_array_class4.cpp | 6 +- tests/json/test_c_array_class4.hpp | 5 - tests/json/test_c_array_class5.cpp | 6 +- tests/json/test_c_array_class5.hpp | 5 - tests/json/test_const_fields.cpp | 6 +- tests/json/test_const_fields.hpp | 5 - tests/json/test_custom_class1.cpp | 5 +- tests/json/test_custom_class1.hpp | 4 - tests/json/test_custom_class2.cpp | 11 +- tests/json/test_custom_class2.hpp | 4 - tests/json/test_custom_class3.cpp | 6 +- tests/json/test_custom_class3.hpp | 4 - tests/json/test_custom_class4.cpp | 6 +- tests/json/test_custom_class4.hpp | 4 - tests/json/test_custom_constructor.cpp | 20 +- tests/json/test_custom_constructor.hpp | 4 - tests/json/test_default_values.cpp | 6 +- tests/json/test_default_values.hpp | 4 - tests/json/test_deque.cpp | 6 +- tests/json/test_deque.hpp | 4 - tests/json/test_email.cpp | 6 +- tests/json/test_email.hpp | 4 - tests/json/test_empty_object.cpp | 6 +- tests/json/test_empty_object.hpp | 4 - tests/json/test_enum1.cpp | 6 +- tests/json/test_enum1.hpp | 4 - tests/json/test_enum2.cpp | 6 +- tests/json/test_enum2.hpp | 4 - tests/json/test_enum3.cpp | 6 +- tests/json/test_enum3.hpp | 4 - tests/json/test_enum4.cpp | 5 +- tests/json/test_enum4.hpp | 4 - tests/json/test_enum5.cpp | 6 +- tests/json/test_enum5.hpp | 4 - tests/json/test_enum6.cpp | 6 +- tests/json/test_enum6.hpp | 4 - tests/json/test_enum7.cpp | 10 +- tests/json/test_enum7.hpp | 4 - tests/json/test_error_messages.cpp | 22 +- tests/json/test_error_messages.hpp | 4 - tests/json/test_field_variant.cpp | 6 +- tests/json/test_field_variant.hpp | 4 - tests/json/test_flag_enum1.cpp | 6 +- tests/json/test_flag_enum1.hpp | 4 - tests/json/test_flag_enum2.cpp | 6 +- tests/json/test_flag_enum2.hpp | 4 - tests/json/test_flag_enum_with_int.cpp | 6 +- tests/json/test_flag_enum_with_int.hpp | 4 - tests/json/test_flatten.cpp | 6 +- tests/json/test_flatten.hpp | 4 - tests/json/test_flatten_anonymous.cpp | 6 +- tests/json/test_flatten_anonymous.hpp | 4 - tests/json/test_forward_list.cpp | 6 +- tests/json/test_forward_list.hpp | 4 - tests/json/test_inheritance.cpp | 8 +- tests/json/test_inheritance.hpp | 3 - tests/json/test_inheritance2.cpp | 8 +- tests/json/test_inheritance2.hpp | 3 - tests/json/test_inside_function.cpp | 6 +- tests/json/test_inside_function.hpp | 4 - tests/json/test_json_schema.cpp | 17 +- tests/json/test_json_schema.hpp | 4 - tests/json/test_list.cpp | 6 +- tests/json/test_list.hpp | 4 - tests/json/test_literal.cpp | 6 +- tests/json/test_literal.hpp | 4 - tests/json/test_literal_map.cpp | 6 +- tests/json/test_literal_map.hpp | 4 - tests/json/test_literal_unordered_map.cpp | 9 +- tests/json/test_literal_unordered_map.hpp | 4 - tests/json/test_map.cpp | 6 +- tests/json/test_map.hpp | 4 - tests/json/test_map_with_key_validation.cpp | 6 +- tests/json/test_map_with_key_validation.hpp | 4 - tests/json/test_meta_fields.cpp | 20 +- tests/json/test_meta_fields.hpp | 4 - tests/json/test_monster_example.cpp | 6 +- tests/json/test_monster_example.hpp | 4 - tests/json/test_move_replace.cpp | 6 +- tests/json/test_move_replace.hpp | 4 - tests/json/test_multimap.cpp | 6 +- tests/json/test_multimap.hpp | 4 - tests/json/test_multiset.cpp | 6 +- tests/json/test_multiset.hpp | 4 - tests/json/test_one_of.cpp | 6 +- tests/json/test_one_of.hpp | 4 - tests/json/test_optional_fields.cpp | 6 +- tests/json/test_optional_fields.hpp | 4 - tests/json/test_readme_example.cpp | 6 +- tests/json/test_readme_example.hpp | 4 - tests/json/test_ref.cpp | 6 +- tests/json/test_ref.hpp | 4 - tests/json/test_replace.cpp | 6 +- tests/json/test_replace.hpp | 4 - tests/json/test_replace2.cpp | 6 +- tests/json/test_replace2.hpp | 4 - tests/json/test_replace_flatten.cpp | 6 +- tests/json/test_replace_flatten.hpp | 4 - tests/json/test_replace_flatten2.cpp | 6 +- tests/json/test_replace_flatten2.hpp | 4 - tests/json/test_replace_with_other_struct.cpp | 6 +- tests/json/test_replace_with_other_struct.hpp | 4 - .../json/test_replace_with_other_struct2.cpp | 6 +- .../json/test_replace_with_other_struct2.hpp | 4 - tests/json/test_result.cpp | 6 +- tests/json/test_result.hpp | 4 - tests/json/test_save_load.cpp | 15 +- tests/json/test_save_load.hpp | 4 - tests/json/test_set.cpp | 6 +- tests/json/test_set.hpp | 4 - tests/json/test_shared_ptr.cpp | 5 +- tests/json/test_shared_ptr.hpp | 4 - tests/json/test_size.cpp | 6 +- tests/json/test_size.hpp | 4 - tests/json/test_std_ref.cpp | 15 +- tests/json/test_std_ref.hpp | 3 - tests/json/test_string_map.cpp | 6 +- tests/json/test_string_map.hpp | 4 - tests/json/test_string_unordered_map.cpp | 8 +- tests/json/test_string_unordered_map.hpp | 4 - tests/json/test_tagged_union.cpp | 6 +- tests/json/test_tagged_union.hpp | 4 - tests/json/test_tagged_union2.cpp | 6 +- tests/json/test_tagged_union2.hpp | 4 - tests/json/test_tagged_union3.cpp | 6 +- tests/json/test_tagged_union3.hpp | 4 - tests/json/test_timestamp.cpp | 11 +- tests/json/test_timestamp.hpp | 4 - tests/json/test_transform.cpp | 5 +- tests/json/test_transform.hpp | 4 - tests/json/test_unique_ptr.cpp | 6 +- tests/json/test_unique_ptr.hpp | 4 - tests/json/test_unique_ptr2.cpp | 6 +- tests/json/test_unique_ptr2.hpp | 4 - tests/json/test_unnamed_namespace.cpp | 7 +- tests/json/test_unnamed_namespace.hpp | 4 - tests/json/test_unordered_map.cpp | 9 +- tests/json/test_unordered_map.hpp | 4 - tests/json/test_unordered_multimap.cpp | 8 +- tests/json/test_unordered_multimap.hpp | 4 - tests/json/test_unordered_multiset.cpp | 8 +- tests/json/test_unordered_multiset.hpp | 4 - tests/json/test_unordered_set.cpp | 8 +- tests/json/test_unordered_set.hpp | 4 - tests/json/test_variant.cpp | 6 +- tests/json/test_variant.hpp | 4 - tests/json/test_view.cpp | 6 +- tests/json/test_view.hpp | 4 - tests/json/test_wstring.cpp | 6 +- tests/json/test_wstring.hpp | 3 - tests/json/tests.cpp | 196 ------------------ tests/json/write_and_read.hpp | 44 ++-- 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/toml/CMakeLists.txt | 15 +- tests/toml/test_array.cpp | 8 +- tests/toml/test_array.hpp | 4 - tests/toml/test_box.cpp | 7 +- tests/toml/test_box.hpp | 4 - tests/toml/test_custom_class1.cpp | 7 +- tests/toml/test_custom_class1.hpp | 4 - tests/toml/test_custom_class3.cpp | 7 +- tests/toml/test_custom_class3.hpp | 4 - tests/toml/test_custom_class4.cpp | 7 +- tests/toml/test_custom_class4.hpp | 4 - tests/toml/test_custom_constructor.cpp | 57 ----- tests/toml/test_custom_constructor.hpp | 4 - tests/toml/test_default_values.cpp | 6 +- tests/toml/test_default_values.hpp | 4 - tests/toml/test_deque.cpp | 6 +- tests/toml/test_deque.hpp | 4 - tests/toml/test_enum.cpp | 6 +- tests/toml/test_enum.hpp | 4 - tests/toml/test_field_variant.cpp | 6 +- tests/toml/test_field_variant.hpp | 4 - tests/toml/test_flag_enum.cpp | 5 +- tests/toml/test_flag_enum.hpp | 4 - tests/toml/test_flag_enum_with_int.cpp | 5 +- tests/toml/test_flag_enum_with_int.hpp | 4 - tests/toml/test_flatten.cpp | 6 +- tests/toml/test_flatten.hpp | 4 - tests/toml/test_flatten_anonymous.cpp | 6 +- tests/toml/test_flatten_anonymous.hpp | 4 - tests/toml/test_forward_list.cpp | 6 +- tests/toml/test_forward_list.hpp | 4 - tests/toml/test_literal.cpp | 6 +- tests/toml/test_literal.hpp | 4 - tests/toml/test_literal_map.cpp | 6 +- tests/toml/test_literal_map.hpp | 4 - tests/toml/test_map.cpp | 6 +- tests/toml/test_map.hpp | 4 - tests/toml/test_map_with_key_validation.cpp | 6 +- tests/toml/test_map_with_key_validation.hpp | 4 - tests/toml/test_monster_example.cpp | 6 +- tests/toml/test_monster_example.hpp | 4 - tests/toml/test_readme_example.cpp | 6 +- tests/toml/test_readme_example.hpp | 4 - tests/toml/test_readme_example2.cpp | 5 +- tests/toml/test_readme_example2.hpp | 4 - tests/toml/test_ref.cpp | 6 +- tests/toml/test_ref.hpp | 4 - tests/toml/test_save_load.cpp | 16 +- tests/toml/test_save_load.hpp | 4 - tests/toml/test_set.cpp | 6 +- tests/toml/test_set.hpp | 4 - tests/toml/test_size.cpp | 6 +- tests/toml/test_size.hpp | 4 - tests/toml/test_string_map.cpp | 6 +- tests/toml/test_string_map.hpp | 4 - tests/toml/test_tagged_union.cpp | 7 +- tests/toml/test_tagged_union.hpp | 4 - tests/toml/test_timestamp.cpp | 6 +- tests/toml/test_timestamp.hpp | 4 - tests/toml/test_unique_ptr.cpp | 6 +- tests/toml/test_unique_ptr.hpp | 4 - tests/toml/test_unique_ptr2.cpp | 6 +- tests/toml/test_unique_ptr2.hpp | 4 - tests/toml/test_variant.cpp | 6 +- tests/toml/test_variant.hpp | 4 - tests/toml/test_wstring.cpp | 12 +- tests/toml/test_wstring.hpp | 3 - tests/toml/tests.cpp | 69 ------ tests/toml/write_and_read.hpp | 28 +-- tests/xml/CMakeLists.txt | 16 +- tests/xml/get_pugixml.sh | 3 - tests/xml/test_array.cpp | 8 +- tests/xml/test_array.hpp | 4 - tests/xml/test_attributes.cpp | 52 ----- tests/xml/test_attributes.hpp | 4 - tests/xml/test_box.cpp | 7 +- tests/xml/test_box.hpp | 4 - tests/xml/test_custom_class1.cpp | 7 +- tests/xml/test_custom_class1.hpp | 4 - tests/xml/test_custom_class3.cpp | 7 +- tests/xml/test_custom_class3.hpp | 4 - tests/xml/test_custom_class4.cpp | 7 +- tests/xml/test_custom_class4.hpp | 4 - tests/xml/test_default_values.cpp | 7 +- tests/xml/test_default_values.hpp | 4 - tests/xml/test_deque.cpp | 7 +- tests/xml/test_deque.hpp | 4 - tests/xml/test_enum.cpp | 7 +- tests/xml/test_enum.hpp | 4 - tests/xml/test_field_variant.cpp | 9 +- tests/xml/test_field_variant.hpp | 4 - tests/xml/test_flag_enum.cpp | 6 +- tests/xml/test_flag_enum.hpp | 4 - tests/xml/test_flag_enum_with_int.cpp | 6 +- tests/xml/test_flag_enum_with_int.hpp | 4 - tests/xml/test_flatten.cpp | 7 +- tests/xml/test_flatten.hpp | 4 - tests/xml/test_flatten_anonymous.cpp | 7 +- tests/xml/test_flatten_anonymous.hpp | 4 - tests/xml/test_forward_list.cpp | 7 +- tests/xml/test_forward_list.hpp | 4 - tests/xml/test_literal.cpp | 7 +- tests/xml/test_literal.hpp | 4 - tests/xml/test_literal_map.cpp | 9 +- tests/xml/test_literal_map.hpp | 4 - tests/xml/test_map.cpp | 7 +- tests/xml/test_map.hpp | 4 - tests/xml/test_map_with_key_validation.cpp | 7 +- tests/xml/test_map_with_key_validation.hpp | 4 - tests/xml/test_monster_example.cpp | 13 +- tests/xml/test_monster_example.hpp | 4 - tests/xml/test_readme_example.cpp | 7 +- tests/xml/test_readme_example.hpp | 4 - tests/xml/test_readme_example2.cpp | 23 ++ tests/xml/test_ref.cpp | 7 +- tests/xml/test_ref.hpp | 4 - tests/xml/test_save_load.cpp | 16 +- tests/xml/test_save_load.hpp | 4 - tests/xml/test_set.cpp | 7 +- tests/xml/test_set.hpp | 4 - tests/xml/test_size.cpp | 7 +- tests/xml/test_size.hpp | 4 - tests/xml/test_string_map.cpp | 9 +- tests/xml/test_string_map.hpp | 4 - tests/xml/test_tagged_union.cpp | 8 +- tests/xml/test_tagged_union.hpp | 4 - tests/xml/test_timestamp.cpp | 7 +- tests/xml/test_timestamp.hpp | 4 - tests/xml/test_unique_ptr.cpp | 7 +- tests/xml/test_unique_ptr.hpp | 4 - tests/xml/test_unique_ptr2.cpp | 7 +- tests/xml/test_unique_ptr2.hpp | 4 - tests/xml/test_variant.cpp | 7 +- tests/xml/test_variant.hpp | 4 - tests/xml/test_wstring.cpp | 14 +- tests/xml/test_wstring.hpp | 3 - tests/xml/test_xml_content.cpp | 6 +- tests/xml/test_xml_content.hpp | 4 - tests/xml/tests.cpp | 69 ------ tests/xml/write_and_read.hpp | 31 +-- tests/yaml/CMakeLists.txt | 16 +- tests/yaml/test_array.cpp | 8 +- tests/yaml/test_array.hpp | 4 - tests/yaml/test_box.cpp | 7 +- tests/yaml/test_box.hpp | 4 - tests/yaml/test_custom_class1.cpp | 7 +- tests/yaml/test_custom_class1.hpp | 4 - tests/yaml/test_custom_class3.cpp | 7 +- tests/yaml/test_custom_class3.hpp | 4 - tests/yaml/test_custom_class4.cpp | 7 +- tests/yaml/test_custom_class4.hpp | 4 - tests/yaml/test_custom_constructor.cpp | 57 ----- tests/yaml/test_custom_constructor.hpp | 4 - tests/yaml/test_default_values.cpp | 6 +- tests/yaml/test_default_values.hpp | 4 - tests/yaml/test_deque.cpp | 6 +- tests/yaml/test_deque.hpp | 4 - tests/yaml/test_enum.cpp | 6 +- tests/yaml/test_enum.hpp | 4 - tests/yaml/test_field_variant.cpp | 6 +- tests/yaml/test_field_variant.hpp | 4 - tests/yaml/test_flag_enum.cpp | 5 +- tests/yaml/test_flag_enum.hpp | 4 - tests/yaml/test_flag_enum_with_int.cpp | 5 +- tests/yaml/test_flag_enum_with_int.hpp | 4 - tests/yaml/test_flatten.cpp | 6 +- tests/yaml/test_flatten.hpp | 4 - tests/yaml/test_flatten_anonymous.cpp | 6 +- tests/yaml/test_flatten_anonymous.hpp | 4 - tests/yaml/test_forward_list.cpp | 6 +- tests/yaml/test_forward_list.hpp | 4 - tests/yaml/test_literal.cpp | 6 +- tests/yaml/test_literal.hpp | 4 - tests/yaml/test_literal_map.cpp | 6 +- tests/yaml/test_literal_map.hpp | 4 - tests/yaml/test_map.cpp | 6 +- tests/yaml/test_map.hpp | 4 - tests/yaml/test_map_with_key_validation.cpp | 6 +- tests/yaml/test_map_with_key_validation.hpp | 4 - tests/yaml/test_monster_example.cpp | 6 +- tests/yaml/test_monster_example.hpp | 4 - tests/yaml/test_readme_example.cpp | 6 +- tests/yaml/test_readme_example.hpp | 4 - tests/yaml/test_readme_example2.cpp | 5 +- tests/yaml/test_readme_example2.hpp | 4 - tests/yaml/test_ref.cpp | 6 +- tests/yaml/test_ref.hpp | 4 - tests/yaml/test_save_load.cpp | 16 +- tests/yaml/test_save_load.hpp | 4 - tests/yaml/test_set.cpp | 6 +- tests/yaml/test_set.hpp | 4 - tests/yaml/test_size.cpp | 6 +- tests/yaml/test_size.hpp | 4 - tests/yaml/test_string_map.cpp | 6 +- tests/yaml/test_string_map.hpp | 4 - tests/yaml/test_tagged_union.cpp | 7 +- tests/yaml/test_tagged_union.hpp | 4 - tests/yaml/test_timestamp.cpp | 6 +- tests/yaml/test_timestamp.hpp | 4 - tests/yaml/test_unique_ptr.cpp | 6 +- tests/yaml/test_unique_ptr.hpp | 4 - tests/yaml/test_unique_ptr2.cpp | 6 +- tests/yaml/test_unique_ptr2.hpp | 4 - tests/yaml/test_variant.cpp | 6 +- tests/yaml/test_variant.hpp | 4 - tests/yaml/test_wstring.cpp | 12 +- tests/yaml/test_wstring.hpp | 3 - tests/yaml/tests.cpp | 69 ------ tests/yaml/write_and_read.hpp | 28 +-- vcpkg.json | 4 + 682 files changed, 1126 insertions(+), 4802 deletions(-) delete mode 100644 tests/bson/test_array.hpp delete mode 100644 tests/bson/test_box.hpp delete mode 100644 tests/bson/test_custom_class1.hpp delete mode 100644 tests/bson/test_custom_class3.hpp delete mode 100644 tests/bson/test_custom_class4.hpp delete mode 100644 tests/bson/test_default_values.hpp delete mode 100644 tests/bson/test_deque.hpp delete mode 100644 tests/bson/test_enum.hpp delete mode 100644 tests/bson/test_field_variant.hpp delete mode 100644 tests/bson/test_flag_enum.hpp delete mode 100644 tests/bson/test_flag_enum_with_int.hpp delete mode 100644 tests/bson/test_flatten.hpp delete mode 100644 tests/bson/test_flatten_anonymous.hpp delete mode 100644 tests/bson/test_forward_list.hpp delete mode 100644 tests/bson/test_literal.hpp delete mode 100644 tests/bson/test_literal_map.hpp delete mode 100644 tests/bson/test_map.hpp delete mode 100644 tests/bson/test_map_with_key_validation.hpp delete mode 100644 tests/bson/test_monster_example.hpp delete mode 100644 tests/bson/test_readme_example.hpp delete mode 100644 tests/bson/test_readme_example2.hpp delete mode 100644 tests/bson/test_ref.hpp delete mode 100644 tests/bson/test_save_load.hpp delete mode 100644 tests/bson/test_set.hpp delete mode 100644 tests/bson/test_size.hpp delete mode 100644 tests/bson/test_string_map.hpp delete mode 100644 tests/bson/test_tagged_union.hpp delete mode 100644 tests/bson/test_timestamp.hpp delete mode 100644 tests/bson/test_unique_ptr.hpp delete mode 100644 tests/bson/test_unique_ptr2.hpp delete mode 100644 tests/bson/test_variant.hpp delete mode 100644 tests/bson/test_wstring.hpp delete mode 100644 tests/bson/tests.cpp delete mode 100644 tests/cbor/test_array.hpp delete mode 100644 tests/cbor/test_box.hpp delete mode 100644 tests/cbor/test_custom_class1.hpp delete mode 100644 tests/cbor/test_custom_class3.hpp delete mode 100644 tests/cbor/test_custom_class4.hpp delete mode 100644 tests/cbor/test_default_values.hpp delete mode 100644 tests/cbor/test_deque.hpp delete mode 100644 tests/cbor/test_enum.hpp delete mode 100644 tests/cbor/test_field_variant.hpp delete mode 100644 tests/cbor/test_flag_enum.hpp delete mode 100644 tests/cbor/test_flag_enum_with_int.hpp delete mode 100644 tests/cbor/test_flatten.hpp delete mode 100644 tests/cbor/test_flatten_anonymous.hpp delete mode 100644 tests/cbor/test_forward_list.hpp delete mode 100644 tests/cbor/test_literal.hpp delete mode 100644 tests/cbor/test_literal_map.hpp delete mode 100644 tests/cbor/test_map.hpp delete mode 100644 tests/cbor/test_map_with_key_validation.hpp delete mode 100644 tests/cbor/test_monster_example.hpp delete mode 100644 tests/cbor/test_readme_example.hpp delete mode 100644 tests/cbor/test_readme_example2.hpp delete mode 100644 tests/cbor/test_ref.hpp delete mode 100644 tests/cbor/test_save_load.hpp delete mode 100644 tests/cbor/test_set.hpp delete mode 100644 tests/cbor/test_size.hpp delete mode 100644 tests/cbor/test_string_map.hpp delete mode 100644 tests/cbor/test_tagged_union.hpp delete mode 100644 tests/cbor/test_timestamp.hpp delete mode 100644 tests/cbor/test_unique_ptr.hpp delete mode 100644 tests/cbor/test_unique_ptr2.hpp delete mode 100644 tests/cbor/test_variant.hpp delete mode 100644 tests/cbor/test_wstring.hpp delete mode 100644 tests/cbor/tests.cpp delete mode 100644 tests/flexbuffers/README.md delete mode 100644 tests/flexbuffers/test_all_of.cpp delete mode 100644 tests/flexbuffers/test_all_of.hpp delete mode 100644 tests/flexbuffers/test_anonymous_fields.cpp delete mode 100644 tests/flexbuffers/test_anonymous_fields.hpp create mode 100644 tests/flexbuffers/test_array.cpp delete mode 100644 tests/flexbuffers/test_box.hpp delete mode 100644 tests/flexbuffers/test_custom_class1.hpp delete mode 100644 tests/flexbuffers/test_custom_class2.cpp delete mode 100644 tests/flexbuffers/test_custom_class2.hpp delete mode 100644 tests/flexbuffers/test_custom_class3.hpp create mode 100644 tests/flexbuffers/test_custom_class4.cpp delete mode 100644 tests/flexbuffers/test_custom_constructor.cpp delete mode 100644 tests/flexbuffers/test_custom_constructor.hpp rename tests/flexbuffers/{test_optional_fields.cpp => test_default_values.cpp} (51%) delete mode 100644 tests/flexbuffers/test_deque.hpp create mode 100644 tests/flexbuffers/test_enum.cpp delete mode 100644 tests/flexbuffers/test_field_variant.hpp create mode 100644 tests/flexbuffers/test_flag_enum.cpp create mode 100644 tests/flexbuffers/test_flag_enum_with_int.cpp create mode 100644 tests/flexbuffers/test_flatten.cpp delete mode 100644 tests/flexbuffers/test_flatten_anonymous.hpp delete mode 100644 tests/flexbuffers/test_forward_list.hpp delete mode 100644 tests/flexbuffers/test_list.cpp delete mode 100644 tests/flexbuffers/test_list.hpp delete mode 100644 tests/flexbuffers/test_literal.hpp create mode 100644 tests/flexbuffers/test_literal_map.cpp delete mode 100644 tests/flexbuffers/test_map.hpp create mode 100644 tests/flexbuffers/test_map_with_key_validation.cpp rename tests/flexbuffers/{test_monster_example1.cpp => test_monster_example.cpp} (69%) delete mode 100644 tests/flexbuffers/test_monster_example1.hpp delete mode 100644 tests/flexbuffers/test_monster_example2.cpp delete mode 100644 tests/flexbuffers/test_monster_example2.hpp delete mode 100644 tests/flexbuffers/test_multimap.cpp delete mode 100644 tests/flexbuffers/test_multimap.hpp delete mode 100644 tests/flexbuffers/test_multiset.cpp delete mode 100644 tests/flexbuffers/test_multiset.hpp delete mode 100644 tests/flexbuffers/test_optional_fields.hpp delete mode 100644 tests/flexbuffers/test_readme_example.hpp create mode 100644 tests/flexbuffers/test_readme_example2.cpp delete mode 100644 tests/flexbuffers/test_ref.hpp delete mode 100644 tests/flexbuffers/test_save_load.hpp delete mode 100644 tests/flexbuffers/test_set.hpp create mode 100644 tests/flexbuffers/test_size.cpp delete mode 100644 tests/flexbuffers/test_string_map.hpp delete mode 100644 tests/flexbuffers/test_string_unordered_map.cpp delete mode 100644 tests/flexbuffers/test_string_unordered_map.hpp delete mode 100644 tests/flexbuffers/test_tagged_union.hpp create mode 100644 tests/flexbuffers/test_timestamp.cpp delete mode 100644 tests/flexbuffers/test_unique_ptr.hpp delete mode 100644 tests/flexbuffers/test_unique_ptr2.hpp delete mode 100644 tests/flexbuffers/test_unordered_map.cpp delete mode 100644 tests/flexbuffers/test_unordered_map.hpp delete mode 100644 tests/flexbuffers/test_unordered_multimap.cpp delete mode 100644 tests/flexbuffers/test_unordered_multimap.hpp delete mode 100644 tests/flexbuffers/test_unordered_multiset.cpp delete mode 100644 tests/flexbuffers/test_unordered_multiset.hpp delete mode 100644 tests/flexbuffers/test_unordered_set.cpp delete mode 100644 tests/flexbuffers/test_unordered_set.hpp delete mode 100644 tests/flexbuffers/test_variant.hpp delete mode 100644 tests/flexbuffers/test_wstring.hpp delete mode 100644 tests/flexbuffers/tests.cpp delete mode 100644 tests/json/test_all_of.hpp delete mode 100644 tests/json/test_alphanumeric_map.hpp delete mode 100644 tests/json/test_alphanumeric_unordered_map.hpp delete mode 100644 tests/json/test_and_then.hpp delete mode 100644 tests/json/test_anonymous_fields.hpp delete mode 100644 tests/json/test_any_of.hpp delete mode 100644 tests/json/test_apply.hpp delete mode 100644 tests/json/test_array.hpp delete mode 100644 tests/json/test_as.hpp delete mode 100644 tests/json/test_as2.hpp delete mode 100644 tests/json/test_as_flatten.hpp delete mode 100644 tests/json/test_box.hpp delete mode 100644 tests/json/test_box2.hpp delete mode 100644 tests/json/test_c_array_class1.hpp delete mode 100644 tests/json/test_c_array_class2.hpp delete mode 100644 tests/json/test_c_array_class3.hpp delete mode 100644 tests/json/test_c_array_class4.hpp delete mode 100644 tests/json/test_c_array_class5.hpp delete mode 100644 tests/json/test_const_fields.hpp delete mode 100644 tests/json/test_custom_class1.hpp delete mode 100644 tests/json/test_custom_class2.hpp delete mode 100644 tests/json/test_custom_class3.hpp delete mode 100644 tests/json/test_custom_class4.hpp delete mode 100644 tests/json/test_custom_constructor.hpp delete mode 100644 tests/json/test_default_values.hpp delete mode 100644 tests/json/test_deque.hpp delete mode 100644 tests/json/test_email.hpp delete mode 100644 tests/json/test_empty_object.hpp delete mode 100644 tests/json/test_enum1.hpp delete mode 100644 tests/json/test_enum2.hpp delete mode 100644 tests/json/test_enum3.hpp delete mode 100644 tests/json/test_enum4.hpp delete mode 100644 tests/json/test_enum5.hpp delete mode 100644 tests/json/test_enum6.hpp delete mode 100644 tests/json/test_enum7.hpp delete mode 100644 tests/json/test_error_messages.hpp delete mode 100644 tests/json/test_field_variant.hpp delete mode 100644 tests/json/test_flag_enum1.hpp delete mode 100644 tests/json/test_flag_enum2.hpp delete mode 100644 tests/json/test_flag_enum_with_int.hpp delete mode 100644 tests/json/test_flatten.hpp delete mode 100644 tests/json/test_flatten_anonymous.hpp delete mode 100644 tests/json/test_forward_list.hpp delete mode 100644 tests/json/test_inheritance.hpp delete mode 100644 tests/json/test_inheritance2.hpp delete mode 100644 tests/json/test_inside_function.hpp delete mode 100644 tests/json/test_json_schema.hpp delete mode 100644 tests/json/test_list.hpp delete mode 100644 tests/json/test_literal.hpp delete mode 100644 tests/json/test_literal_map.hpp delete mode 100644 tests/json/test_literal_unordered_map.hpp delete mode 100644 tests/json/test_map.hpp delete mode 100644 tests/json/test_map_with_key_validation.hpp delete mode 100644 tests/json/test_meta_fields.hpp delete mode 100644 tests/json/test_monster_example.hpp delete mode 100644 tests/json/test_move_replace.hpp delete mode 100644 tests/json/test_multimap.hpp delete mode 100644 tests/json/test_multiset.hpp delete mode 100644 tests/json/test_one_of.hpp delete mode 100644 tests/json/test_optional_fields.hpp delete mode 100644 tests/json/test_readme_example.hpp delete mode 100644 tests/json/test_ref.hpp delete mode 100644 tests/json/test_replace.hpp delete mode 100644 tests/json/test_replace2.hpp delete mode 100644 tests/json/test_replace_flatten.hpp delete mode 100644 tests/json/test_replace_flatten2.hpp delete mode 100644 tests/json/test_replace_with_other_struct.hpp delete mode 100644 tests/json/test_replace_with_other_struct2.hpp delete mode 100644 tests/json/test_result.hpp delete mode 100644 tests/json/test_save_load.hpp delete mode 100644 tests/json/test_set.hpp delete mode 100644 tests/json/test_shared_ptr.hpp delete mode 100644 tests/json/test_size.hpp delete mode 100644 tests/json/test_std_ref.hpp delete mode 100644 tests/json/test_string_map.hpp delete mode 100644 tests/json/test_string_unordered_map.hpp delete mode 100644 tests/json/test_tagged_union.hpp delete mode 100644 tests/json/test_tagged_union2.hpp delete mode 100644 tests/json/test_tagged_union3.hpp delete mode 100644 tests/json/test_timestamp.hpp delete mode 100644 tests/json/test_transform.hpp delete mode 100644 tests/json/test_unique_ptr.hpp delete mode 100644 tests/json/test_unique_ptr2.hpp delete mode 100644 tests/json/test_unnamed_namespace.hpp delete mode 100644 tests/json/test_unordered_map.hpp delete mode 100644 tests/json/test_unordered_multimap.hpp delete mode 100644 tests/json/test_unordered_multiset.hpp delete mode 100644 tests/json/test_unordered_set.hpp delete mode 100644 tests/json/test_variant.hpp delete mode 100644 tests/json/test_view.hpp delete mode 100644 tests/json/test_wstring.hpp delete mode 100644 tests/json/tests.cpp 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 100644 tests/toml/test_array.hpp delete mode 100644 tests/toml/test_box.hpp delete mode 100644 tests/toml/test_custom_class1.hpp delete mode 100644 tests/toml/test_custom_class3.hpp delete mode 100644 tests/toml/test_custom_class4.hpp delete mode 100644 tests/toml/test_custom_constructor.cpp delete mode 100644 tests/toml/test_custom_constructor.hpp delete mode 100644 tests/toml/test_default_values.hpp delete mode 100644 tests/toml/test_deque.hpp delete mode 100644 tests/toml/test_enum.hpp delete mode 100644 tests/toml/test_field_variant.hpp delete mode 100644 tests/toml/test_flag_enum.hpp delete mode 100644 tests/toml/test_flag_enum_with_int.hpp delete mode 100644 tests/toml/test_flatten.hpp delete mode 100644 tests/toml/test_flatten_anonymous.hpp delete mode 100644 tests/toml/test_forward_list.hpp delete mode 100644 tests/toml/test_literal.hpp delete mode 100644 tests/toml/test_literal_map.hpp delete mode 100644 tests/toml/test_map.hpp delete mode 100644 tests/toml/test_map_with_key_validation.hpp delete mode 100644 tests/toml/test_monster_example.hpp delete mode 100644 tests/toml/test_readme_example.hpp delete mode 100644 tests/toml/test_readme_example2.hpp delete mode 100644 tests/toml/test_ref.hpp delete mode 100644 tests/toml/test_save_load.hpp delete mode 100644 tests/toml/test_set.hpp delete mode 100644 tests/toml/test_size.hpp delete mode 100644 tests/toml/test_string_map.hpp delete mode 100644 tests/toml/test_tagged_union.hpp delete mode 100644 tests/toml/test_timestamp.hpp delete mode 100644 tests/toml/test_unique_ptr.hpp delete mode 100644 tests/toml/test_unique_ptr2.hpp delete mode 100644 tests/toml/test_variant.hpp delete mode 100644 tests/toml/test_wstring.hpp delete mode 100644 tests/toml/tests.cpp delete mode 100755 tests/xml/get_pugixml.sh delete mode 100644 tests/xml/test_array.hpp delete mode 100644 tests/xml/test_attributes.cpp delete mode 100644 tests/xml/test_attributes.hpp delete mode 100644 tests/xml/test_box.hpp delete mode 100644 tests/xml/test_custom_class1.hpp delete mode 100644 tests/xml/test_custom_class3.hpp delete mode 100644 tests/xml/test_custom_class4.hpp delete mode 100644 tests/xml/test_default_values.hpp delete mode 100644 tests/xml/test_deque.hpp delete mode 100644 tests/xml/test_enum.hpp delete mode 100644 tests/xml/test_field_variant.hpp delete mode 100644 tests/xml/test_flag_enum.hpp delete mode 100644 tests/xml/test_flag_enum_with_int.hpp delete mode 100644 tests/xml/test_flatten.hpp delete mode 100644 tests/xml/test_flatten_anonymous.hpp delete mode 100644 tests/xml/test_forward_list.hpp delete mode 100644 tests/xml/test_literal.hpp delete mode 100644 tests/xml/test_literal_map.hpp delete mode 100644 tests/xml/test_map.hpp delete mode 100644 tests/xml/test_map_with_key_validation.hpp delete mode 100644 tests/xml/test_monster_example.hpp delete mode 100644 tests/xml/test_readme_example.hpp create mode 100644 tests/xml/test_readme_example2.cpp delete mode 100644 tests/xml/test_ref.hpp delete mode 100644 tests/xml/test_save_load.hpp delete mode 100644 tests/xml/test_set.hpp delete mode 100644 tests/xml/test_size.hpp delete mode 100644 tests/xml/test_string_map.hpp delete mode 100644 tests/xml/test_tagged_union.hpp delete mode 100644 tests/xml/test_timestamp.hpp delete mode 100644 tests/xml/test_unique_ptr.hpp delete mode 100644 tests/xml/test_unique_ptr2.hpp delete mode 100644 tests/xml/test_variant.hpp delete mode 100644 tests/xml/test_wstring.hpp delete mode 100644 tests/xml/test_xml_content.hpp delete mode 100644 tests/xml/tests.cpp delete mode 100644 tests/yaml/test_array.hpp delete mode 100644 tests/yaml/test_box.hpp delete mode 100644 tests/yaml/test_custom_class1.hpp delete mode 100644 tests/yaml/test_custom_class3.hpp delete mode 100644 tests/yaml/test_custom_class4.hpp delete mode 100644 tests/yaml/test_custom_constructor.cpp delete mode 100644 tests/yaml/test_custom_constructor.hpp delete mode 100644 tests/yaml/test_default_values.hpp delete mode 100644 tests/yaml/test_deque.hpp delete mode 100644 tests/yaml/test_enum.hpp delete mode 100644 tests/yaml/test_field_variant.hpp delete mode 100644 tests/yaml/test_flag_enum.hpp delete mode 100644 tests/yaml/test_flag_enum_with_int.hpp delete mode 100644 tests/yaml/test_flatten.hpp delete mode 100644 tests/yaml/test_flatten_anonymous.hpp delete mode 100644 tests/yaml/test_forward_list.hpp delete mode 100644 tests/yaml/test_literal.hpp delete mode 100644 tests/yaml/test_literal_map.hpp delete mode 100644 tests/yaml/test_map.hpp delete mode 100644 tests/yaml/test_map_with_key_validation.hpp delete mode 100644 tests/yaml/test_monster_example.hpp delete mode 100644 tests/yaml/test_readme_example.hpp delete mode 100644 tests/yaml/test_readme_example2.hpp delete mode 100644 tests/yaml/test_ref.hpp delete mode 100644 tests/yaml/test_save_load.hpp delete mode 100644 tests/yaml/test_set.hpp delete mode 100644 tests/yaml/test_size.hpp delete mode 100644 tests/yaml/test_string_map.hpp delete mode 100644 tests/yaml/test_tagged_union.hpp delete mode 100644 tests/yaml/test_timestamp.hpp delete mode 100644 tests/yaml/test_unique_ptr.hpp delete mode 100644 tests/yaml/test_unique_ptr2.hpp delete mode 100644 tests/yaml/test_variant.hpp delete mode 100644 tests/yaml/test_wstring.hpp delete mode 100644 tests/yaml/tests.cpp diff --git a/.gitignore b/.gitignore index 36fa4976..48757cde 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ *.cbor *.json *.fb +*.flexbuf *.msgpack *.toml *.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bdb1b33..cc26bcb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ option(REFLECTCPP_YAML "Enable YAML support" OFF) option(REFLECTCPP_BUILD_TESTS "Build tests" OFF) set(REFLECTCPP_USE_VCPKG_DEFAULT OFF) -if (REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_YAML) +if (REFLECTCPP_BUILD_TESTS OR REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_YAML) # enable vcpkg per default if require features other than JSON set(REFLECTCPP_USE_VCPKG_DEFAULT ON) endif() @@ -85,10 +85,14 @@ endif () target_compile_options(reflectcpp PRIVATE -Wall) if (REFLECTCPP_BUILD_TESTS) + if (MSVC) + set(REFLECT_CPP_GTEST_LIB "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/gtest${CMAKE_STATIC_LIBRARY_SUFFIX}") + else () + set(REFLECT_CPP_GTEST_LIB "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libgtest${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif () add_subdirectory(tests) endif () - include(GNUInstallDirs) include(CMakePackageConfigHelpers) diff --git a/README.md b/README.md index 579dcbd5..14cf64ca 100644 --- a/README.md +++ b/README.md @@ -530,6 +530,17 @@ vcpkg is a great, but very ambitious and complex project (just like C++ is a gre ## Compiling and running the tests +reflect-cpp uses vcpkg for dependency management, including +gtest, which is required for the tests. + +```bash +# bootstrap vcpkg if you haven't done so already +git submodule update --init +./vcpkg/bootstrap-vcpkg.sh # Linux, macOS +./vcpkg/bootstrap-vcpkg.bat # Windows +# You may be prompted to install additional dependencies. +``` + ### JSON only To compile the tests, do the following: @@ -551,12 +562,6 @@ To run the tests, do the following: To compile the tests with serialization formats other than JSON, do the following: ```bash -# bootstrap vcpkg if you haven't done so already -git submodule update --init -./vcpkg/bootstrap-vcpkg.sh # Linux, macOS -./vcpkg/bootstrap-vcpkg.bat # Windows -# You may be prompted to install additional dependencies. - cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release cmake --build build -j 4 # gcc, clang cmake --build build --config Release -j 4 # MSVC diff --git a/tests/bson/CMakeLists.txt b/tests/bson/CMakeLists.txt index 318ba7a0..40d4d467 100644 --- a/tests/bson/CMakeLists.txt +++ b/tests/bson/CMakeLists.txt @@ -1,8 +1,18 @@ project(reflect-cpp-bson-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-bson-tests ${SOURCES}) +add_executable( + reflect-cpp-bson-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) target_include_directories(reflect-cpp-bson-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") -target_link_libraries(reflect-cpp-bson-tests PRIVATE reflectcpp) + +target_link_libraries( + reflect-cpp-bson-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/bson/test_array.cpp b/tests/bson/test_array.cpp index 970ffd11..c50694fc 100644 --- a/tests/bson/test_array.cpp +++ b/tests/bson/test_array.cpp @@ -1,5 +1,3 @@ -#include "test_array.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include // Make sure things still compile when -// rfl.hpp is included after rfl/bson.hpp. +// rfl.hpp is included after rfl/cbor.hpp. #include #include "write_and_read.hpp" @@ -21,9 +19,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(bson, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/bson/test_array.hpp b/tests/bson/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/bson/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_box.cpp b/tests/bson/test_box.cpp index fdb3516a..c570a725 100644 --- a/tests/bson/test_box.cpp +++ b/tests/bson/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(bson, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/bson/test_box.hpp b/tests/bson/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/bson/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_custom_class1.cpp b/tests/bson/test_custom_class1.cpp index fe8d0ea0..ddc9cc76 100644 --- a/tests/bson/test_custom_class1.cpp +++ b/tests/bson/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(bson, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/bson/test_custom_class1.hpp b/tests/bson/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/bson/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/bson/test_custom_class3.cpp b/tests/bson/test_custom_class3.cpp index 598364b1..75cd152e 100644 --- a/tests/bson/test_custom_class3.cpp +++ b/tests/bson/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(bson, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/bson/test_custom_class3.hpp b/tests/bson/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/bson/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/bson/test_custom_class4.cpp b/tests/bson/test_custom_class4.cpp index 2b3b3bac..8a0edea4 100644 --- a/tests/bson/test_custom_class4.cpp +++ b/tests/bson/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(bson, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/bson/test_custom_class4.hpp b/tests/bson/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/bson/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/bson/test_default_values.cpp b/tests/bson/test_default_values.cpp index f6af2352..99c9de6c 100644 --- a/tests/bson/test_default_values.cpp +++ b/tests/bson/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(bson, test_default_values) { const auto bart = Person{.first_name = "Bart"}; const auto lisa = Person{.first_name = "Lisa"}; const auto maggie = Person{.first_name = "Maggie"}; diff --git a/tests/bson/test_default_values.hpp b/tests/bson/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/bson/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/bson/test_deque.cpp b/tests/bson/test_deque.cpp index 6dfa5803..6483cb8a 100644 --- a/tests/bson/test_deque.cpp +++ b/tests/bson/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(bson, 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/bson/test_deque.hpp b/tests/bson/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/bson/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_enum.cpp b/tests/bson/test_enum.cpp index d4d56a8b..4390668c 100644 --- a/tests/bson/test_enum.cpp +++ b/tests/bson/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(bson, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/bson/test_enum.hpp b/tests/bson/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/bson/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/bson/test_field_variant.cpp b/tests/bson/test_field_variant.cpp index 8b17665f..ef4e20ab 100644 --- a/tests/bson/test_field_variant.cpp +++ b/tests/bson/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(bson, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/bson/test_field_variant.hpp b/tests/bson/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/bson/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/bson/test_flag_enum.cpp b/tests/bson/test_flag_enum.cpp index 1d3f76af..1570d740 100644 --- a/tests/bson/test_flag_enum.cpp +++ b/tests/bson/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(bson, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/bson/test_flag_enum.hpp b/tests/bson/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/bson/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/bson/test_flag_enum_with_int.cpp b/tests/bson/test_flag_enum_with_int.cpp index 4c7deefe..60b0ac02 100644 --- a/tests/bson/test_flag_enum_with_int.cpp +++ b/tests/bson/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(bson, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/bson/test_flag_enum_with_int.hpp b/tests/bson/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/bson/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/bson/test_flatten.cpp b/tests/bson/test_flatten.cpp index c7f1d9be..66388a31 100644 --- a/tests/bson/test_flatten.cpp +++ b/tests/bson/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(bson, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/bson/test_flatten.hpp b/tests/bson/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/bson/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_flatten_anonymous.cpp b/tests/bson/test_flatten_anonymous.cpp index 05e61464..15cd0cf2 100644 --- a/tests/bson/test_flatten_anonymous.cpp +++ b/tests/bson/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(bson, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/bson/test_flatten_anonymous.hpp b/tests/bson/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/bson/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/bson/test_forward_list.cpp b/tests/bson/test_forward_list.cpp index dd8d9e56..81f0699e 100644 --- a/tests/bson/test_forward_list.cpp +++ b/tests/bson/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(bson, 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/bson/test_forward_list.hpp b/tests/bson/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/bson/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/bson/test_literal.cpp b/tests/bson/test_literal.cpp index 00578178..12cbad32 100644 --- a/tests/bson/test_literal.cpp +++ b/tests/bson/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(bson, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/bson/test_literal.hpp b/tests/bson/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/bson/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_literal_map.cpp b/tests/bson/test_literal_map.cpp index 9bbebafb..83710d55 100644 --- a/tests/bson/test_literal_map.cpp +++ b/tests/bson/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(bson, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/bson/test_literal_map.hpp b/tests/bson/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/bson/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/bson/test_map.cpp b/tests/bson/test_map.cpp index e37ce564..537e77f6 100644 --- a/tests/bson/test_map.cpp +++ b/tests/bson/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(bson, 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/bson/test_map.hpp b/tests/bson/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/bson/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_map_with_key_validation.cpp b/tests/bson/test_map_with_key_validation.cpp index e758219d..991f3e50 100644 --- a/tests/bson/test_map_with_key_validation.cpp +++ b/tests/bson/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(bson, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/bson/test_map_with_key_validation.hpp b/tests/bson/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/bson/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/bson/test_monster_example.cpp b/tests/bson/test_monster_example.cpp index 052d8390..49887c35 100644 --- a/tests/bson/test_monster_example.cpp +++ b/tests/bson/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(bson, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/bson/test_monster_example.hpp b/tests/bson/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/bson/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/bson/test_readme_example.cpp b/tests/bson/test_readme_example.cpp index 4e6f8ee0..e42d8817 100644 --- a/tests/bson/test_readme_example.cpp +++ b/tests/bson/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(bson, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/bson/test_readme_example.hpp b/tests/bson/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/bson/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/bson/test_readme_example2.cpp b/tests/bson/test_readme_example2.cpp index a2d212a4..f93de197 100644 --- a/tests/bson/test_readme_example2.cpp +++ b/tests/bson/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(bson, test_readme_example2) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/bson/test_readme_example2.hpp b/tests/bson/test_readme_example2.hpp deleted file mode 100644 index 5c6b011c..00000000 --- a/tests/bson/test_readme_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example2 { -void test(); -} - diff --git a/tests/bson/test_ref.cpp b/tests/bson/test_ref.cpp index 32a32e6c..7b7ca3a3 100644 --- a/tests/bson/test_ref.cpp +++ b/tests/bson/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(bson, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/bson/test_ref.hpp b/tests/bson/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/bson/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_save_load.cpp b/tests/bson/test_save_load.cpp index d51c34c8..a72dc2a9 100644 --- a/tests/bson/test_save_load.cpp +++ b/tests/bson/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(bson, test_save_load) { const auto bart = Person{.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19", @@ -59,12 +57,6 @@ void test() { const auto string1 = rfl::bson::write(homer1); const auto string2 = rfl::bson::write(homer2); - if (string1 != string2) { - std::cout << "Test failed. Content was not identical." << std::endl - << std::endl; - return; - } - - std::cout << "OK" << std::endl << std::endl; + EXPECT_EQ(string1, string2); } } // namespace test_save_load diff --git a/tests/bson/test_save_load.hpp b/tests/bson/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/bson/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/bson/test_set.cpp b/tests/bson/test_set.cpp index 9f2516ce..ec6f8030 100644 --- a/tests/bson/test_set.cpp +++ b/tests/bson/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(bson, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/bson/test_set.hpp b/tests/bson/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/bson/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_size.cpp b/tests/bson/test_size.cpp index c37b9bd8..0de9abf5 100644 --- a/tests/bson/test_size.cpp +++ b/tests/bson/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(bson, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/bson/test_size.hpp b/tests/bson/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/bson/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_string_map.cpp b/tests/bson/test_string_map.cpp index cb4fb903..b4aef817 100644 --- a/tests/bson/test_string_map.cpp +++ b/tests/bson/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(bson, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/bson/test_string_map.hpp b/tests/bson/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/bson/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/bson/test_tagged_union.cpp b/tests/bson/test_tagged_union.cpp index a9dd1abc..630b65e6 100644 --- a/tests/bson/test_tagged_union.cpp +++ b/tests/bson/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(bson, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/bson/test_tagged_union.hpp b/tests/bson/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/bson/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/bson/test_timestamp.cpp b/tests/bson/test_timestamp.cpp index 8af261d1..c57e06fc 100644 --- a/tests/bson/test_timestamp.cpp +++ b/tests/bson/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(bson, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/bson/test_timestamp.hpp b/tests/bson/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/bson/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_unique_ptr.cpp b/tests/bson/test_unique_ptr.cpp index b1833533..4091de86 100644 --- a/tests/bson/test_unique_ptr.cpp +++ b/tests/bson/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(bson, 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/bson/test_unique_ptr.hpp b/tests/bson/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/bson/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/bson/test_unique_ptr2.cpp b/tests/bson/test_unique_ptr2.cpp index e3007267..a9ba69b6 100644 --- a/tests/bson/test_unique_ptr2.cpp +++ b/tests/bson/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(bson, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/bson/test_unique_ptr2.hpp b/tests/bson/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/bson/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/bson/test_variant.cpp b/tests/bson/test_variant.cpp index cc3d6cbe..cea0b0b4 100644 --- a/tests/bson/test_variant.cpp +++ b/tests/bson/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(bson, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/bson/test_variant.hpp b/tests/bson/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/bson/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/bson/test_wstring.cpp b/tests/bson/test_wstring.cpp index ba6202c0..0eaaf93c 100644 --- a/tests/bson/test_wstring.cpp +++ b/tests/bson/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(bson, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/bson/test_wstring.hpp b/tests/bson/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/bson/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/bson/tests.cpp b/tests/bson/tests.cpp deleted file mode 100644 index 8a9fe0fb..00000000 --- a/tests/bson/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/bson/write_and_read.hpp b/tests/bson/write_and_read.hpp index f009be61..15096a38 100644 --- a/tests/bson/write_and_read.hpp +++ b/tests/bson/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::bson::write(_struct); - - const auto res = rfl::bson::read(bytes1); - - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << std::endl; - return; - } - - const auto bytes2 = rfl::bson::write(res.value()); - - if (bytes1.size() != bytes2.size()) { - std::cout << "Test failed on write. Number of bytes was different." - << std::endl - << std::endl; - return; - } - - if (bytes1 != bytes2) { - std::cout << "Test failed on write. Content was not identical." << std::endl - << std::endl; - return; - } - - std::cout << "OK" << std::endl << std::endl; + const auto serialized1 = rfl::bson::write(_struct); + const auto res = rfl::bson::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::bson::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/cbor/CMakeLists.txt b/tests/cbor/CMakeLists.txt index 7f457ee5..ba5a8e0f 100644 --- a/tests/cbor/CMakeLists.txt +++ b/tests/cbor/CMakeLists.txt @@ -1,8 +1,19 @@ project(reflect-cpp-cbor-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-cbor-tests ${SOURCES}) +add_executable( + reflect-cpp-cbor-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) +target_include_directories(reflect-cpp-cbor-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") target_include_directories(reflect-cpp-cbor-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/tinycbor") -target_link_libraries(reflect-cpp-cbor-tests PRIVATE reflectcpp) + +target_link_libraries( + reflect-cpp-cbor-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/cbor/test_array.cpp b/tests/cbor/test_array.cpp index 108f730e..55274d49 100644 --- a/tests/cbor/test_array.cpp +++ b/tests/cbor/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(cbor, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/cbor/test_array.hpp b/tests/cbor/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/cbor/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_box.cpp b/tests/cbor/test_box.cpp index fdb3516a..3fd68a69 100644 --- a/tests/cbor/test_box.cpp +++ b/tests/cbor/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(cbor, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/cbor/test_box.hpp b/tests/cbor/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/cbor/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_custom_class1.cpp b/tests/cbor/test_custom_class1.cpp index fe8d0ea0..448ac187 100644 --- a/tests/cbor/test_custom_class1.cpp +++ b/tests/cbor/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(cbor, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/cbor/test_custom_class1.hpp b/tests/cbor/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/cbor/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/cbor/test_custom_class3.cpp b/tests/cbor/test_custom_class3.cpp index 598364b1..991df513 100644 --- a/tests/cbor/test_custom_class3.cpp +++ b/tests/cbor/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(cbor, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/cbor/test_custom_class3.hpp b/tests/cbor/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/cbor/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/cbor/test_custom_class4.cpp b/tests/cbor/test_custom_class4.cpp index 2b3b3bac..45b6d914 100644 --- a/tests/cbor/test_custom_class4.cpp +++ b/tests/cbor/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(cbor, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/cbor/test_custom_class4.hpp b/tests/cbor/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/cbor/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/cbor/test_default_values.cpp b/tests/cbor/test_default_values.cpp index f6af2352..d69109e2 100644 --- a/tests/cbor/test_default_values.cpp +++ b/tests/cbor/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(cbor, test_default_values) { const auto bart = Person{.first_name = "Bart"}; const auto lisa = Person{.first_name = "Lisa"}; const auto maggie = Person{.first_name = "Maggie"}; diff --git a/tests/cbor/test_default_values.hpp b/tests/cbor/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/cbor/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/cbor/test_deque.cpp b/tests/cbor/test_deque.cpp index 6dfa5803..d897da5d 100644 --- a/tests/cbor/test_deque.cpp +++ b/tests/cbor/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(cbor, 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/cbor/test_deque.hpp b/tests/cbor/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/cbor/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_enum.cpp b/tests/cbor/test_enum.cpp index d4d56a8b..4e485288 100644 --- a/tests/cbor/test_enum.cpp +++ b/tests/cbor/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(cbor, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/cbor/test_enum.hpp b/tests/cbor/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/cbor/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/cbor/test_field_variant.cpp b/tests/cbor/test_field_variant.cpp index 8b17665f..1276609d 100644 --- a/tests/cbor/test_field_variant.cpp +++ b/tests/cbor/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(cbor, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/cbor/test_field_variant.hpp b/tests/cbor/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/cbor/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/cbor/test_flag_enum.cpp b/tests/cbor/test_flag_enum.cpp index 1d3f76af..3473dc84 100644 --- a/tests/cbor/test_flag_enum.cpp +++ b/tests/cbor/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(cbor, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/cbor/test_flag_enum.hpp b/tests/cbor/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/cbor/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/cbor/test_flag_enum_with_int.cpp b/tests/cbor/test_flag_enum_with_int.cpp index 4c7deefe..78f558f8 100644 --- a/tests/cbor/test_flag_enum_with_int.cpp +++ b/tests/cbor/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(cbor, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/cbor/test_flag_enum_with_int.hpp b/tests/cbor/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/cbor/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/cbor/test_flatten.cpp b/tests/cbor/test_flatten.cpp index c7f1d9be..3896a206 100644 --- a/tests/cbor/test_flatten.cpp +++ b/tests/cbor/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(cbor, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/cbor/test_flatten.hpp b/tests/cbor/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/cbor/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_flatten_anonymous.cpp b/tests/cbor/test_flatten_anonymous.cpp index 05e61464..3a90ba02 100644 --- a/tests/cbor/test_flatten_anonymous.cpp +++ b/tests/cbor/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(cbor, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/cbor/test_flatten_anonymous.hpp b/tests/cbor/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/cbor/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/cbor/test_forward_list.cpp b/tests/cbor/test_forward_list.cpp index dd8d9e56..444d581f 100644 --- a/tests/cbor/test_forward_list.cpp +++ b/tests/cbor/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(cbor, 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/cbor/test_forward_list.hpp b/tests/cbor/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/cbor/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/cbor/test_literal.cpp b/tests/cbor/test_literal.cpp index 00578178..d444ec33 100644 --- a/tests/cbor/test_literal.cpp +++ b/tests/cbor/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(cbor, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/cbor/test_literal.hpp b/tests/cbor/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/cbor/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_literal_map.cpp b/tests/cbor/test_literal_map.cpp index 9bbebafb..3c2a096d 100644 --- a/tests/cbor/test_literal_map.cpp +++ b/tests/cbor/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(cbor, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/cbor/test_literal_map.hpp b/tests/cbor/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/cbor/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/cbor/test_map.cpp b/tests/cbor/test_map.cpp index e37ce564..4ac14474 100644 --- a/tests/cbor/test_map.cpp +++ b/tests/cbor/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(cbor, 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/cbor/test_map.hpp b/tests/cbor/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/cbor/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_map_with_key_validation.cpp b/tests/cbor/test_map_with_key_validation.cpp index e758219d..9286e2ad 100644 --- a/tests/cbor/test_map_with_key_validation.cpp +++ b/tests/cbor/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(cbor, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/cbor/test_map_with_key_validation.hpp b/tests/cbor/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/cbor/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/cbor/test_monster_example.cpp b/tests/cbor/test_monster_example.cpp index 052d8390..3a27276d 100644 --- a/tests/cbor/test_monster_example.cpp +++ b/tests/cbor/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(cbor, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/cbor/test_monster_example.hpp b/tests/cbor/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/cbor/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/cbor/test_readme_example.cpp b/tests/cbor/test_readme_example.cpp index 4e6f8ee0..092608fd 100644 --- a/tests/cbor/test_readme_example.cpp +++ b/tests/cbor/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(cbor, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/cbor/test_readme_example.hpp b/tests/cbor/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/cbor/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/cbor/test_readme_example2.cpp b/tests/cbor/test_readme_example2.cpp index a2d212a4..b1b69c42 100644 --- a/tests/cbor/test_readme_example2.cpp +++ b/tests/cbor/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(cbor, test_readme_example2) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/cbor/test_readme_example2.hpp b/tests/cbor/test_readme_example2.hpp deleted file mode 100644 index 5c6b011c..00000000 --- a/tests/cbor/test_readme_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example2 { -void test(); -} - diff --git a/tests/cbor/test_ref.cpp b/tests/cbor/test_ref.cpp index 32a32e6c..653783fd 100644 --- a/tests/cbor/test_ref.cpp +++ b/tests/cbor/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(cbor, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/cbor/test_ref.hpp b/tests/cbor/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/cbor/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_save_load.cpp b/tests/cbor/test_save_load.cpp index c2b19a43..4f4dcbd1 100644 --- a/tests/cbor/test_save_load.cpp +++ b/tests/cbor/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(cbor, 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::cbor::write(homer1); const auto string2 = rfl::cbor::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/cbor/test_save_load.hpp b/tests/cbor/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/cbor/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/cbor/test_set.cpp b/tests/cbor/test_set.cpp index 9f2516ce..66f6d2e1 100644 --- a/tests/cbor/test_set.cpp +++ b/tests/cbor/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(cbor, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/cbor/test_set.hpp b/tests/cbor/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/cbor/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_size.cpp b/tests/cbor/test_size.cpp index c37b9bd8..984fa087 100644 --- a/tests/cbor/test_size.cpp +++ b/tests/cbor/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(cbor, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/cbor/test_size.hpp b/tests/cbor/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/cbor/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_string_map.cpp b/tests/cbor/test_string_map.cpp index cb4fb903..70934445 100644 --- a/tests/cbor/test_string_map.cpp +++ b/tests/cbor/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(cbor, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/cbor/test_string_map.hpp b/tests/cbor/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/cbor/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/cbor/test_tagged_union.cpp b/tests/cbor/test_tagged_union.cpp index a9dd1abc..adbf422c 100644 --- a/tests/cbor/test_tagged_union.cpp +++ b/tests/cbor/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(cbor, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/cbor/test_tagged_union.hpp b/tests/cbor/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/cbor/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/cbor/test_timestamp.cpp b/tests/cbor/test_timestamp.cpp index 8af261d1..da86861c 100644 --- a/tests/cbor/test_timestamp.cpp +++ b/tests/cbor/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(cbor, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/cbor/test_timestamp.hpp b/tests/cbor/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/cbor/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_unique_ptr.cpp b/tests/cbor/test_unique_ptr.cpp index b1833533..fc667206 100644 --- a/tests/cbor/test_unique_ptr.cpp +++ b/tests/cbor/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(cbor, 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/cbor/test_unique_ptr.hpp b/tests/cbor/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/cbor/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/cbor/test_unique_ptr2.cpp b/tests/cbor/test_unique_ptr2.cpp index e3007267..b2f83eed 100644 --- a/tests/cbor/test_unique_ptr2.cpp +++ b/tests/cbor/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(cbor, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/cbor/test_unique_ptr2.hpp b/tests/cbor/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/cbor/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/cbor/test_variant.cpp b/tests/cbor/test_variant.cpp index cc3d6cbe..82f83604 100644 --- a/tests/cbor/test_variant.cpp +++ b/tests/cbor/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(cbor, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/cbor/test_variant.hpp b/tests/cbor/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/cbor/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/cbor/test_wstring.cpp b/tests/cbor/test_wstring.cpp index ba6202c0..36759b16 100644 --- a/tests/cbor/test_wstring.cpp +++ b/tests/cbor/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(cbor, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/cbor/test_wstring.hpp b/tests/cbor/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/cbor/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/cbor/tests.cpp b/tests/cbor/tests.cpp deleted file mode 100644 index 8a9fe0fb..00000000 --- a/tests/cbor/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/cbor/write_and_read.hpp b/tests/cbor/write_and_read.hpp index 0864ad53..f0078856 100644 --- a/tests/cbor/write_and_read.hpp +++ b/tests/cbor/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::cbor::write(_struct); - - const auto res = rfl::cbor::read(bytes1); - - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << std::endl; - return; - } - - const auto bytes2 = rfl::cbor::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::cbor::write(_struct); + const auto res = rfl::cbor::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::cbor::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/flexbuffers/CMakeLists.txt b/tests/flexbuffers/CMakeLists.txt index 19125e19..aaf8a05f 100644 --- a/tests/flexbuffers/CMakeLists.txt +++ b/tests/flexbuffers/CMakeLists.txt @@ -1,7 +1,18 @@ -project(reflect-cpp-flexbuffer-tests) +project(reflect-cpp-flexbuffers-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-flexbuffers-tests ${SOURCES}) +add_executable( + reflect-cpp-flexbuffers-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) -target_link_libraries(reflect-cpp-flexbuffers-tests PRIVATE reflectcpp) +target_include_directories(reflect-cpp-flexbuffers-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + +target_link_libraries( + reflect-cpp-flexbuffers-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/flexbuffers/README.md b/tests/flexbuffers/README.md deleted file mode 100644 index 9acf80e9..00000000 --- a/tests/flexbuffers/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# Tests for flexbuffers - -This folder contains the tests for flexbuffers. A Docker-based build pipeline is provided for Linux users. - -Build the Docker container containing the build environment: - -``` -./build_docker.sh -``` - -Compile the tests: - -``` -./compile.sh -``` - -Run the tests: - -``` -./build/reflect-cpp-flatbuffers-tests -``` - -To run the scripts, you may have to run `chmod +x build_docker.sh` and `chmod +x compile.sh` first. diff --git a/tests/flexbuffers/test_all_of.cpp b/tests/flexbuffers/test_all_of.cpp deleted file mode 100644 index a75d37a8..00000000 --- a/tests/flexbuffers/test_all_of.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "test_all_of.hpp" - -#include -#include -#include -#include -#include - -// Make sure things still compile when -// rfl.hpp is included after rfl/flexbuf.hpp. -#include - -#include "write_and_read.hpp" - -namespace test_all_of { - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - using Age = rfl::Validator, rfl::Maximum<130>>>; - - struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"age", Age> age; - }; - - const auto homer = - Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; - - write_and_read(homer); -} -} // namespace test_all_of diff --git a/tests/flexbuffers/test_all_of.hpp b/tests/flexbuffers/test_all_of.hpp deleted file mode 100644 index 082d508a..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_anonymous_fields.cpp b/tests/flexbuffers/test_anonymous_fields.cpp deleted file mode 100644 index 8ff2a704..00000000 --- a/tests/flexbuffers/test_anonymous_fields.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "test_anonymous_fields.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_anonymous_fields { - -using Age = rfl::Validator, rfl::Maximum<130>>>; - -struct Person { - std::string first_name; - std::string last_name; - rfl::Timestamp<"%Y-%m-%d"> birthday; - Age age; - rfl::Email email; - std::vector children; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto bart = Person{.first_name = "Bart", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 10, - .email = "bart@simpson.com"}; - - const auto lisa = Person{.first_name = "Lisa", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 8, - .email = "lisa@simpson.com"}; - - const auto maggie = Person{.first_name = "Maggie", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 0, - .email = "maggie@simpson.com"}; - - const auto homer = - Person{.first_name = "Homer", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 45, - .email = "homer@simpson.com", - .children = std::vector({bart, lisa, maggie})}; - - write_and_read(homer); -} -} // namespace test_anonymous_fields diff --git a/tests/flexbuffers/test_anonymous_fields.hpp b/tests/flexbuffers/test_anonymous_fields.hpp deleted file mode 100644 index 16c47d36..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_array.cpp b/tests/flexbuffers/test_array.cpp new file mode 100644 index 00000000..a4bebf0a --- /dev/null +++ b/tests/flexbuffers/test_array.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include + +// Make sure things still compile when +// rfl.hpp is included after rfl/cbor.hpp. +#include + +#include "write_and_read.hpp" + +namespace test_array { + +struct Person { + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children = nullptr; +}; + +TEST(flexbuf, test_array) { + auto bart = Person{.first_name = "Bart"}; + + auto lisa = Person{.first_name = "Lisa"}; + + auto maggie = Person{.first_name = "Maggie"}; + + const auto homer = Person{ + .first_name = "Homer", + .children = std::make_unique>(std::array{ + std::move(bart), std::move(lisa), std::move(maggie)})}; + + write_and_read(homer); +} +} // namespace test_array diff --git a/tests/flexbuffers/test_box.cpp b/tests/flexbuffers/test_box.cpp index 00625393..3f45b087 100644 --- a/tests/flexbuffers/test_box.cpp +++ b/tests/flexbuffers/test_box.cpp @@ -1,9 +1,6 @@ -#include "test_box.hpp" - #include #include #include -#include #include #include #include @@ -14,13 +11,15 @@ namespace test_box { struct DecisionTree { struct Leaf { - rfl::Field<"value", double> value; + using Tag = rfl::Literal<"Leaf">; + double value; }; struct Node { - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", rfl::Box> lesser; - rfl::Field<"right", rfl::Box> greater; + using Tag = rfl::Literal<"Node">; + rfl::Rename<"criticalValue", double> critical_value; + rfl::Box lesser; + rfl::Box greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -28,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(flexbuf, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; @@ -43,5 +40,6 @@ void test() { const DecisionTree tree{.leaf_or_node = std::move(node)}; write_and_read(tree); + } } // namespace test_box diff --git a/tests/flexbuffers/test_box.hpp b/tests/flexbuffers/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/flexbuffers/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_custom_class1.cpp b/tests/flexbuffers/test_custom_class1.cpp index c0685f84..899e899e 100644 --- a/tests/flexbuffers/test_custom_class1.cpp +++ b/tests/flexbuffers/test_custom_class1.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class1.hpp" - #include #include #include -#include #include #include #include @@ -14,9 +11,9 @@ namespace test_custom_class1 { struct Person { struct PersonImpl { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::vector> children = rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::vector children; }; using ReflectionType = PersonImpl; @@ -32,9 +29,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/flexbuffers/test_custom_class1.hpp b/tests/flexbuffers/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_custom_class2.cpp b/tests/flexbuffers/test_custom_class2.cpp deleted file mode 100644 index 6e8487c5..00000000 --- a/tests/flexbuffers/test_custom_class2.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "test_custom_class2.hpp" - -#include -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_custom_class2 { - -struct Person { - Person(const std::string& _first_name, const std::string& _last_name, - const int _age) - : first_name_(_first_name), last_name_(_last_name), age_(_age) {} - - const auto& first_name() const { return first_name_; } - - const auto& last_name() const { return last_name_; } - - auto age() const { return age_; } - - private: - std::string first_name_; - std::string last_name_; - int age_; -}; - -struct PersonImpl { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"age", int> age; - - static PersonImpl from_class(const Person& _p) noexcept { - return PersonImpl{.first_name = _p.first_name(), - .last_name = _p.last_name(), - .age = _p.age()}; - } - - Person to_class() const { return Person(first_name(), last_name(), age()); } -}; - -} // namespace test_custom_class2 - -namespace rfl { -namespace parsing { - -template -struct Parser - : public CustomParser {}; - -} // namespace parsing -} // namespace rfl - -namespace test_custom_class2 { - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto bart = test_custom_class2::Person("Bart", "Simpson", 10); - - write_and_read(bart); -} - -} // namespace test_custom_class2 diff --git a/tests/flexbuffers/test_custom_class2.hpp b/tests/flexbuffers/test_custom_class2.hpp deleted file mode 100644 index 21cfbd51..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_custom_class3.cpp b/tests/flexbuffers/test_custom_class3.cpp index fdd799d4..edd41c42 100644 --- a/tests/flexbuffers/test_custom_class3.cpp +++ b/tests/flexbuffers/test_custom_class3.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class3.hpp" - #include #include #include -#include #include #include #include @@ -13,11 +10,9 @@ namespace test_custom_class3 { struct Person { - Person(const std::string& _first_name, - const rfl::Box& _last_name, int _age) - : first_name_(_first_name), - last_name_(rfl::make_box(*_last_name)), - age_(_age) {} + Person(const std::string& _first_name, const std::string& _last_name, + const int _age) + : first_name_(_first_name), last_name_(_last_name), age_(_age) {} const auto& first_name() const { return first_name_; } @@ -27,22 +22,23 @@ struct Person { private: std::string first_name_; - rfl::Box last_name_; + std::string last_name_; int age_; }; struct PersonImpl { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", rfl::Box> last_name; - rfl::Field<"age", int> age; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name; + int age; static PersonImpl from_class(const Person& _p) noexcept { return PersonImpl{.first_name = _p.first_name(), - .last_name = rfl::make_box(*_p.last_name()), + .last_name = _p.last_name(), .age = _p.age()}; } -}; + Person to_class() const { return Person(first_name(), last_name(), age); } +}; } // namespace test_custom_class3 namespace rfl { @@ -58,11 +54,8 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto bart = test_custom_class3::Person( - "Bart", rfl::make_box("Simpson"), 10); +TEST(flexbuf, test_custom_class3) { + const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); } diff --git a/tests/flexbuffers/test_custom_class3.hpp b/tests/flexbuffers/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_custom_class4.cpp b/tests/flexbuffers/test_custom_class4.cpp new file mode 100644 index 00000000..1ba35f4a --- /dev/null +++ b/tests/flexbuffers/test_custom_class4.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_custom_class4 { + +struct Person { + Person(const std::string& _first_name, + const rfl::Box& _last_name, int _age) + : first_name_(_first_name), + last_name_(rfl::make_box(*_last_name)), + age_(_age) {} + + const auto& first_name() const { return first_name_; } + + const auto& last_name() const { return last_name_; } + + auto age() const { return age_; } + + private: + std::string first_name_; + rfl::Box last_name_; + int age_; +}; + +struct PersonImpl { + rfl::Field<"firstName", std::string> first_name; + rfl::Field<"lastName", rfl::Box> last_name; + rfl::Field<"age", int> age; + + static PersonImpl from_class(const Person& _p) noexcept { + return PersonImpl{.first_name = _p.first_name(), + .last_name = rfl::make_box(*_p.last_name()), + .age = _p.age()}; + } +}; + +} // namespace test_custom_class4 + +namespace rfl { +namespace parsing { + +template +struct Parser + : public CustomParser {}; + +} // namespace parsing +} // namespace rfl + +namespace test_custom_class4 { + +TEST(flexbuf, test_custom_class4) { + const auto bart = test_custom_class4::Person( + "Bart", rfl::make_box("Simpson"), 10); + + write_and_read(bart); +} +} // namespace test_custom_class4 diff --git a/tests/flexbuffers/test_custom_constructor.cpp b/tests/flexbuffers/test_custom_constructor.cpp deleted file mode 100644 index bad09e24..00000000 --- a/tests/flexbuffers/test_custom_constructor.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "test_custom_constructor.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_custom_constructor { - -struct Person { - static rfl::Result from_flexbuf( - typename rfl::flexbuf::Reader::InputVarType _obj) { - /// This only exists for the purpose of the test. - const auto change_first_name = [](auto&& _person) { - return rfl::replace(std::move(_person), - rfl::Field<"firstName", std::string>("Bart")); - }; - const auto from_nt = [](auto&& _nt) { - return rfl::from_named_tuple(std::move(_nt)); - }; - return rfl::flexbuf::read>(_obj) - .transform(from_nt) - .transform(change_first_name); - } - - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto person1 = Person{ - .first_name = "Homer", .last_name = "Simpson", .birthday = "1987-04-19"}; - - const auto bytes = rfl::flexbuf::write(person1); - - const auto res = rfl::flexbuf::read(bytes); - - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl; - return; - } - - 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; - } -} -} // namespace test_custom_constructor diff --git a/tests/flexbuffers/test_custom_constructor.hpp b/tests/flexbuffers/test_custom_constructor.hpp deleted file mode 100644 index 013721d0..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_optional_fields.cpp b/tests/flexbuffers/test_default_values.cpp similarity index 51% rename from tests/flexbuffers/test_optional_fields.cpp rename to tests/flexbuffers/test_default_values.cpp index f15c35a8..31d68ebf 100644 --- a/tests/flexbuffers/test_optional_fields.cpp +++ b/tests/flexbuffers/test_default_values.cpp @@ -1,36 +1,28 @@ -#include "test_optional_fields.hpp" - +#include #include #include -#include #include #include #include #include "write_and_read.hpp" -namespace test_optional_fields { +namespace test_default_values { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::optional>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_default_values) { const auto bart = Person{.first_name = "Bart"}; - const auto lisa = Person{.first_name = "Lisa"}; - const auto maggie = Person{.first_name = "Maggie"}; - const auto homer = Person{.first_name = "Homer", .children = std::vector({bart, lisa, maggie})}; write_and_read(homer); } -} // namespace test_optional_fields +} // namespace test_default_values diff --git a/tests/flexbuffers/test_deque.cpp b/tests/flexbuffers/test_deque.cpp index 7e1d1139..aa120c37 100644 --- a/tests/flexbuffers/test_deque.cpp +++ b/tests/flexbuffers/test_deque.cpp @@ -1,8 +1,5 @@ -#include "test_deque.hpp" - #include #include -#include #include #include #include @@ -12,15 +9,12 @@ namespace test_deque { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_default_values) { auto children = std::make_unique>(); children->emplace_back(Person{.first_name = "Bart"}); children->emplace_back(Person{.first_name = "Lisa"}); @@ -30,5 +24,6 @@ void test() { Person{.first_name = "Homer", .children = std::move(children)}; write_and_read(homer); + } } // namespace test_deque diff --git a/tests/flexbuffers/test_deque.hpp b/tests/flexbuffers/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/flexbuffers/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_enum.cpp b/tests/flexbuffers/test_enum.cpp new file mode 100644 index 00000000..7802e8af --- /dev/null +++ b/tests/flexbuffers/test_enum.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_enum { + +enum class Color { red, green, blue, yellow }; + +struct Circle { + float radius; + Color color; +}; + +TEST(flexbuf, test_enum) { + const auto circle = Circle{.radius = 2.0, .color = Color::green}; + + write_and_read(circle); +} + +} // namespace test_enum diff --git a/tests/flexbuffers/test_field_variant.cpp b/tests/flexbuffers/test_field_variant.cpp index e87ce872..2c1a830f 100644 --- a/tests/flexbuffers/test_field_variant.cpp +++ b/tests/flexbuffers/test_field_variant.cpp @@ -1,9 +1,6 @@ -#include "test_field_variant.hpp" - #include #include #include -#include #include #include #include @@ -13,25 +10,23 @@ namespace test_field_variant { struct Circle { - rfl::Field<"radius", double> radius; + double radius; }; struct Rectangle { - rfl::Field<"height", double> height; - rfl::Field<"width", double> width; + double height; + double width; }; struct Square { - rfl::Field<"width", double> width; + double width; }; 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(flexbuf, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/flexbuffers/test_field_variant.hpp b/tests/flexbuffers/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_flag_enum.cpp b/tests/flexbuffers/test_flag_enum.cpp new file mode 100644 index 00000000..ccba582b --- /dev/null +++ b/tests/flexbuffers/test_flag_enum.cpp @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_flag_enum { + +enum class Color { + red = 256, + green = 512, + blue = 1024, + yellow = 2048, + orange = (256 | 2048) // red + yellow = orange +}; + +inline Color operator|(Color c1, Color c2) { + return static_cast(static_cast(c1) | static_cast(c2)); +} + +struct Circle { + float radius; + Color color; +}; + +TEST(flexbuf, test_flag_enum) { + const auto circle = + Circle{.radius = 2.0, .color = Color::blue | Color::orange}; + + write_and_read(circle); +} + +} // namespace test_flag_enum diff --git a/tests/flexbuffers/test_flag_enum_with_int.cpp b/tests/flexbuffers/test_flag_enum_with_int.cpp new file mode 100644 index 00000000..1dc35155 --- /dev/null +++ b/tests/flexbuffers/test_flag_enum_with_int.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_flag_enum_with_int { + +enum class Color { + red = 256, + green = 512, + blue = 1024, + yellow = 2048, + orange = (256 | 2048) // red + yellow = orange +}; + +inline Color operator|(Color c1, Color c2) { + return static_cast(static_cast(c1) | static_cast(c2)); +} + +struct Circle { + float radius; + Color color; +}; + +TEST(flexbuf, test_flag_enum_with_int) { + const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; + + write_and_read(circle); +} + +} // namespace test_flag_enum_with_int diff --git a/tests/flexbuffers/test_flatten.cpp b/tests/flexbuffers/test_flatten.cpp new file mode 100644 index 00000000..fa7d9431 --- /dev/null +++ b/tests/flexbuffers/test_flatten.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_flatten { + +struct Person { + rfl::Field<"firstName", std::string> first_name; + rfl::Field<"lastName", rfl::Box> last_name; + rfl::Field<"age", int> age; +}; + +struct Employee { + rfl::Flatten person; + rfl::Field<"employer", rfl::Box> employer; + rfl::Field<"salary", float> salary; +}; + +TEST(flexbuf, test_flatten) { + const auto employee = Employee{ + .person = Person{.first_name = "Homer", + .last_name = rfl::make_box("Simpson"), + .age = 45}, + .employer = rfl::make_box("Mr. Burns"), + .salary = 60000.0}; + + write_and_read(employee); +} +} // namespace test_flatten diff --git a/tests/flexbuffers/test_flatten_anonymous.cpp b/tests/flexbuffers/test_flatten_anonymous.cpp index 7db468dd..13ba28de 100644 --- a/tests/flexbuffers/test_flatten_anonymous.cpp +++ b/tests/flexbuffers/test_flatten_anonymous.cpp @@ -1,9 +1,6 @@ -#include "test_flatten_anonymous.hpp" - #include #include #include -#include #include #include #include @@ -24,9 +21,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), @@ -36,4 +31,5 @@ void test() { write_and_read(employee); } + } // namespace test_flatten_anonymous diff --git a/tests/flexbuffers/test_flatten_anonymous.hpp b/tests/flexbuffers/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_forward_list.cpp b/tests/flexbuffers/test_forward_list.cpp index 4743e019..c747a3f5 100644 --- a/tests/flexbuffers/test_forward_list.cpp +++ b/tests/flexbuffers/test_forward_list.cpp @@ -1,8 +1,5 @@ -#include "test_forward_list.hpp" - #include #include -#include #include #include #include @@ -12,15 +9,12 @@ namespace test_forward_list { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_forward_list) { auto children = std::make_unique>(); children->emplace_front(Person{.first_name = "Maggie"}); children->emplace_front(Person{.first_name = "Lisa"}); @@ -30,5 +24,6 @@ void test() { Person{.first_name = "Homer", .children = std::move(children)}; write_and_read(homer); + } } // namespace test_forward_list diff --git a/tests/flexbuffers/test_forward_list.hpp b/tests/flexbuffers/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_list.cpp b/tests/flexbuffers/test_list.cpp deleted file mode 100644 index 5190d244..00000000 --- a/tests/flexbuffers/test_list.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "test_list.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_list { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - auto children = std::make_unique>(); - children->emplace_back(Person{.first_name = "Bart"}); - children->emplace_back(Person{.first_name = "Lisa"}); - children->emplace_back(Person{.first_name = "Maggie"}); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - write_and_read(homer); -} -} // namespace test_list diff --git a/tests/flexbuffers/test_list.hpp b/tests/flexbuffers/test_list.hpp deleted file mode 100644 index 956d36cc..00000000 --- a/tests/flexbuffers/test_list.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_list{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_literal.cpp b/tests/flexbuffers/test_literal.cpp index af92ef3e..9c5d8b8b 100644 --- a/tests/flexbuffers/test_literal.cpp +++ b/tests/flexbuffers/test_literal.cpp @@ -1,9 +1,6 @@ -#include "test_literal.hpp" - #include #include #include -#include #include #include #include @@ -16,14 +13,12 @@ using FirstName = rfl::Literal<"Homer", "Marge", "Bart", "Lisa", "Maggie">; using LastName = rfl::Literal<"Simpson">; struct Person { - rfl::Field<"firstName", FirstName> first_name; - rfl::Field<"lastName", LastName> last_name = rfl::default_value; - rfl::Field<"children", std::vector> children = rfl::default_value; + rfl::Rename<"firstName", FirstName> first_name; + rfl::Rename<"lastName", LastName> last_name; + std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/flexbuffers/test_literal.hpp b/tests/flexbuffers/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/flexbuffers/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_literal_map.cpp b/tests/flexbuffers/test_literal_map.cpp new file mode 100644 index 00000000..46fa5d14 --- /dev/null +++ b/tests/flexbuffers/test_literal_map.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_literal_map { + +using FieldName = rfl::Literal<"firstName", "lastName">; + +TEST(flexbuf, test_literal_map) { + std::map> homer; + homer.insert(std::make_pair(FieldName::make<"firstName">(), + std::make_unique("Homer"))); + homer.insert(std::make_pair(FieldName::make<"lastName">(), + std::make_unique("Simpson"))); + + write_and_read(homer); +} +} // namespace test_literal_map diff --git a/tests/flexbuffers/test_map.cpp b/tests/flexbuffers/test_map.cpp index 97a8a74b..119290bb 100644 --- a/tests/flexbuffers/test_map.cpp +++ b/tests/flexbuffers/test_map.cpp @@ -1,9 +1,6 @@ -#include "test_map.hpp" - #include #include #include -#include #include #include @@ -12,19 +9,16 @@ namespace test_map { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::map children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - 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"})); - children->insert(std::make_pair(3, Person{.first_name = "Maggie"})); +TEST(flexbuf, 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"})); + children.insert(std::make_pair("child3", Person{.first_name = "Maggie"})); const auto homer = Person{.first_name = "Homer", .children = std::move(children)}; diff --git a/tests/flexbuffers/test_map.hpp b/tests/flexbuffers/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/flexbuffers/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_map_with_key_validation.cpp b/tests/flexbuffers/test_map_with_key_validation.cpp new file mode 100644 index 00000000..3a978ead --- /dev/null +++ b/tests/flexbuffers/test_map_with_key_validation.cpp @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_map_with_key_validation { + +struct Person { + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children; +}; + +TEST(flexbuf, test_map_with_key_validation) { + auto children = std::make_unique>(); + + children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); + children->insert(std::make_pair("Lisa", Person{.first_name = "Lisa"})); + children->insert(std::make_pair("Maggie", Person{.first_name = "Maggie"})); + + const auto homer = + Person{.first_name = "Homer", .children = std::move(children)}; + + write_and_read(homer); +} +} // namespace test_map_with_key_validation diff --git a/tests/flexbuffers/test_monster_example1.cpp b/tests/flexbuffers/test_monster_example.cpp similarity index 69% rename from tests/flexbuffers/test_monster_example1.cpp rename to tests/flexbuffers/test_monster_example.cpp index b1db84b2..d6c65eb5 100644 --- a/tests/flexbuffers/test_monster_example1.cpp +++ b/tests/flexbuffers/test_monster_example.cpp @@ -1,17 +1,14 @@ -#include "test_monster_example1.hpp" - #include #include -#include #include #include #include #include "write_and_read.hpp" -namespace test_monster_example1 { +namespace test_monster_example { -enum class Color { Red, Green, Blue }; +using Color = rfl::Literal<"Red", "Green", "Blue">; struct Weapon { std::string name; @@ -32,16 +29,14 @@ struct Monster { short hp = 100; std::string name; bool friendly = false; - std::vector inventory; - Color color = Color::Blue; + std::vector inventory; + Color color = Color::make<"Blue">(); std::vector weapons; Equipment equipped; std::vector path; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; @@ -49,19 +44,17 @@ void test() { const auto position = Vec3{1.0f, 2.0f, 3.0f}; - const auto inventory = - std::vector({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + const auto inventory = std::vector({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); const auto orc = Monster{.pos = position, .mana = 150, .hp = 80, .name = "MyMonster", .inventory = inventory, - .color = Color::Red, + .color = Color::make<"Red">(), .weapons = weapons, .equipped = rfl::make_field<"weapon">(axe)}; write_and_read(orc); } - -} // namespace test_monster_example1 +} // namespace test_monster_example diff --git a/tests/flexbuffers/test_monster_example1.hpp b/tests/flexbuffers/test_monster_example1.hpp deleted file mode 100644 index 80cd680d..00000000 --- a/tests/flexbuffers/test_monster_example1.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_monster_example1{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_monster_example2.cpp b/tests/flexbuffers/test_monster_example2.cpp deleted file mode 100644 index 3cb2ab73..00000000 --- a/tests/flexbuffers/test_monster_example2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "test_monster_example2.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_monster_example2 { - -using Color = rfl::Literal<"Red", "Green", "Blue">; - -struct Weapon { - rfl::Field<"name", std::string> name; - rfl::Field<"damage", short> damage; -}; - -using Equipment = rfl::Variant>; - -struct Vec3 { - rfl::Field<"x", float> x; - rfl::Field<"y", float> y; - rfl::Field<"z", float> z; -}; - -struct Monster { - rfl::Field<"pos", Vec3> pos; - rfl::Field<"mana", short> mana = 150; - rfl::Field<"hp", short> hp = 100; - rfl::Field<"name", std::string> name; - rfl::Field<"friendly", bool> friendly = false; - rfl::Field<"inventory", std::vector> inventory; - rfl::Field<"color", Color> color = Color::make<"Blue">(); - rfl::Field<"weapons", std::vector> weapons; - rfl::Field<"equipped", Equipment> equipped; - rfl::Field<"path", std::vector> path; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto sword = Weapon{.name = "Sword", .damage = 3}; - const auto axe = Weapon{.name = "Axe", .damage = 5}; - - const auto weapons = std::vector({sword, axe}); - - const auto position = Vec3{1.0f, 2.0f, 3.0f}; - - const auto inventory = - std::vector({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); - - const auto orc = Monster{.pos = position, - .mana = 150, - .hp = 80, - .name = "MyMonster", - .inventory = inventory, - .color = Color::make<"Red">(), - .weapons = weapons, - .equipped = rfl::make_field<"weapon">(axe), - .path = rfl::default_value}; - - write_and_read(orc); -} -} // namespace test_monster_example2 diff --git a/tests/flexbuffers/test_monster_example2.hpp b/tests/flexbuffers/test_monster_example2.hpp deleted file mode 100644 index 9d82a452..00000000 --- a/tests/flexbuffers/test_monster_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_monster_example2{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_multimap.cpp b/tests/flexbuffers/test_multimap.cpp deleted file mode 100644 index add150d1..00000000 --- a/tests/flexbuffers/test_multimap.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "test_multimap.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_multimap { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - 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"})); - children->insert(std::make_pair(3, Person{.first_name = "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - write_and_read(homer); -} -} // namespace test_multimap diff --git a/tests/flexbuffers/test_multimap.hpp b/tests/flexbuffers/test_multimap.hpp deleted file mode 100644 index 81845572..00000000 --- a/tests/flexbuffers/test_multimap.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_multimap{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_multiset.cpp b/tests/flexbuffers/test_multiset.cpp deleted file mode 100644 index 6a5a31ec..00000000 --- a/tests/flexbuffers/test_multiset.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "test_multiset.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_multiset { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - auto children = std::make_unique>( - std::multiset({"Bart", "Lisa", "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - write_and_read(homer); -} -} // namespace test_multiset diff --git a/tests/flexbuffers/test_multiset.hpp b/tests/flexbuffers/test_multiset.hpp deleted file mode 100644 index adfcf186..00000000 --- a/tests/flexbuffers/test_multiset.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_multiset{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_optional_fields.hpp b/tests/flexbuffers/test_optional_fields.hpp deleted file mode 100644 index 640cab95..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_readme_example.cpp b/tests/flexbuffers/test_readme_example.cpp index 7bc77c80..4212bf18 100644 --- a/tests/flexbuffers/test_readme_example.cpp +++ b/tests/flexbuffers/test_readme_example.cpp @@ -1,8 +1,5 @@ -#include "test_readme_example.hpp" - #include #include -#include #include #include #include @@ -11,49 +8,39 @@ namespace test_readme_example { -using Age = rfl::Validator, rfl::Maximum<130>>>; +using Age = rfl::Validator, rfl::Maximum<130>>; struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; - rfl::Field<"age", Age> age; - rfl::Field<"email", rfl::Email> email; - rfl::Field<"children", std::vector> children; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::string town = "Springfield"; + rfl::Timestamp<"%Y-%m-%d"> birthday; + Age age; + rfl::Email email; + std::vector child; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_readme_example) { const auto bart = Person{.first_name = "Bart", - .last_name = "Simpson", .birthday = "1987-04-19", .age = 10, - .email = "bart@simpson.com", - .children = std::vector()}; - - const auto lisa = Person{ - .first_name = "Lisa", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 8, - .email = "lisa@simpson.com", - .children = rfl::default_value // same as std::vector() - }; - - const auto maggie = - rfl::replace(lisa, rfl::make_field<"firstName">(std::string("Maggie")), - rfl::make_field<"email">(std::string("maggie@simpson.com")), - rfl::make_field<"age">(0)); - - const auto homer = - Person{.first_name = "Homer", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 45, - .email = "homer@simpson.com", - .children = std::vector({bart, lisa, maggie})}; + .email = "bart@simpson.com"}; + + const auto lisa = Person{.first_name = "Lisa", + .birthday = "1987-04-19", + .age = 8, + .email = "lisa@simpson.com"}; + + const auto maggie = Person{.first_name = "Maggie", + .birthday = "1987-04-19", + .age = 0, + .email = "maggie@simpson.com"}; + + const auto homer = Person{.first_name = "Homer", + .birthday = "1987-04-19", + .age = 45, + .email = "homer@simpson.com", + .child = std::vector({bart, lisa, maggie})}; write_and_read(homer); } diff --git a/tests/flexbuffers/test_readme_example.hpp b/tests/flexbuffers/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_readme_example2.cpp b/tests/flexbuffers/test_readme_example2.cpp new file mode 100644 index 00000000..02cabd76 --- /dev/null +++ b/tests/flexbuffers/test_readme_example2.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_readme_example2 { + +struct Person { + std::string first_name; + std::string last_name; + int age; +}; + +TEST(flexbuf, test_readme_example2) { + const auto homer = + Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; + + write_and_read(homer); +} +} // namespace test_readme_example2 diff --git a/tests/flexbuffers/test_ref.cpp b/tests/flexbuffers/test_ref.cpp index 41ceca1c..1e9e6733 100644 --- a/tests/flexbuffers/test_ref.cpp +++ b/tests/flexbuffers/test_ref.cpp @@ -1,9 +1,6 @@ -#include "test_ref.hpp" - #include #include #include -#include #include #include #include @@ -14,13 +11,15 @@ namespace test_ref { struct DecisionTree { struct Leaf { - rfl::Field<"value", double> value; + using Tag = rfl::Literal<"Leaf">; + double value; }; struct Node { - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", rfl::Ref> lesser; - rfl::Field<"right", rfl::Ref> greater; + using Tag = rfl::Literal<"Node">; + rfl::Rename<"criticalValue", double> critical_value; + rfl::Ref lesser; + rfl::Ref greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -28,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(flexbuf, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; @@ -43,5 +40,6 @@ void test() { const DecisionTree tree{.leaf_or_node = std::move(node)}; write_and_read(tree); + } } // namespace test_ref diff --git a/tests/flexbuffers/test_ref.hpp b/tests/flexbuffers/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/flexbuffers/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_save_load.cpp b/tests/flexbuffers/test_save_load.cpp index 9d9d7d7e..5aaa4507 100644 --- a/tests/flexbuffers/test_save_load.cpp +++ b/tests/flexbuffers/test_save_load.cpp @@ -1,5 +1,3 @@ -#include "test_save_load.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include #include -#include "write_and_read.hpp" +#include namespace test_save_load { @@ -16,17 +14,15 @@ using Age = rfl::Validator, rfl::Maximum<130>>>; struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; - rfl::Field<"age", Age> age; - rfl::Field<"email", rfl::Email> email; - rfl::Field<"children", std::vector> children; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name; + rfl::Timestamp<"%Y-%m-%d"> birthday; + Age age; + rfl::Email email; + std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_save_load) { const auto bart = Person{.first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19", @@ -34,19 +30,17 @@ void test() { .email = "bart@simpson.com", .children = std::vector()}; - const auto lisa = Person{ - .first_name = "Lisa", - .last_name = "Simpson", - .birthday = "1987-04-19", - .age = 8, - .email = "lisa@simpson.com", - .children = rfl::default_value // same as std::vector() - }; + const auto lisa = Person{.first_name = "Lisa", + .last_name = "Simpson", + .birthday = "1987-04-19", + .age = 8, + .email = "lisa@simpson.com"}; - const auto maggie = - rfl::replace(lisa, rfl::make_field<"firstName">(std::string("Maggie")), - rfl::make_field<"email">(std::string("maggie@simpson.com")), - rfl::make_field<"age">(0)); + const auto maggie = Person{.first_name = "Maggie", + .last_name = "Simpson", + .birthday = "1987-04-19", + .age = 0, + .email = "maggie@simpson.com"}; const auto homer1 = Person{.first_name = "Homer", @@ -56,19 +50,13 @@ void test() { .email = "homer@simpson.com", .children = std::vector({bart, lisa, maggie})}; - rfl::flexbuf::save("homer.fb", homer1); - - const auto homer2 = rfl::flexbuf::load("homer.fb").value(); + rfl::flexbuf::save("homer.flexbuf", homer1); - const auto bytes1 = rfl::flexbuf::write(homer1); - const auto bytes2 = rfl::flexbuf::write(homer2); + const auto homer2 = rfl::flexbuf::load("homer.flexbuf").value(); - if (bytes1 != bytes2) { - std::cout << "Test failed. Content was not identical." << std::endl - << std::endl; - return; - } + const auto string1 = rfl::flexbuf::write(homer1); + const auto string2 = rfl::flexbuf::write(homer2); - std::cout << "OK" << std::endl << std::endl; + EXPECT_EQ(string1, string2); } } // namespace test_save_load diff --git a/tests/flexbuffers/test_save_load.hpp b/tests/flexbuffers/test_save_load.hpp deleted file mode 100644 index a8829fd1..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_set.cpp b/tests/flexbuffers/test_set.cpp index 4da6eeff..5b7d1031 100644 --- a/tests/flexbuffers/test_set.cpp +++ b/tests/flexbuffers/test_set.cpp @@ -1,8 +1,5 @@ -#include "test_set.hpp" - #include #include -#include #include #include #include @@ -12,15 +9,12 @@ namespace test_set { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/flexbuffers/test_set.hpp b/tests/flexbuffers/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/flexbuffers/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_size.cpp b/tests/flexbuffers/test_size.cpp new file mode 100644 index 00000000..b07f02d5 --- /dev/null +++ b/tests/flexbuffers/test_size.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_size { + +struct Person { + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name; + rfl::Timestamp<"%Y-%m-%d"> birthday; + rfl::Validator, + rfl::Size, rfl::EqualTo<3>>>> + children; +}; + +TEST(flexbuf, test_size) { + const auto bart = Person{ + .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; + + const auto lisa = Person{ + .first_name = "Lisa", .last_name = "Simpson", .birthday = "1987-04-19"}; + + const auto maggie = Person{ + .first_name = "Maggie", .last_name = "Simpson", .birthday = "1987-04-19"}; + + const auto homer = + Person{.first_name = "Homer", + .last_name = "Simpson", + .birthday = "1987-04-19", + .children = std::vector({bart, lisa, maggie})}; + + write_and_read(homer); +} +} // namespace test_size diff --git a/tests/flexbuffers/test_string_map.cpp b/tests/flexbuffers/test_string_map.cpp index fc2157cb..1f45634e 100644 --- a/tests/flexbuffers/test_string_map.cpp +++ b/tests/flexbuffers/test_string_map.cpp @@ -1,19 +1,14 @@ -#include "test_string_map.hpp" - #include #include #include #include -#include #include #include #include "write_and_read.hpp" namespace test_string_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/flexbuffers/test_string_map.hpp b/tests/flexbuffers/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_string_unordered_map.cpp b/tests/flexbuffers/test_string_unordered_map.cpp deleted file mode 100644 index 07241877..00000000 --- a/tests/flexbuffers/test_string_unordered_map.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "test_string_unordered_map.hpp" - -#include -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_string_unordered_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - using Map = std::unordered_map>; - Map homer; - homer.insert( - std::make_pair("firstName", std::make_unique("Homer"))); - homer.insert( - std::make_pair("lastName", std::make_unique("Simpson"))); - - // Unordered maps are unpredictable. We therefore only make sure that this - // compiles. - const auto json_string = rfl::flexbuf::write(homer); - const auto homer2 = rfl::flexbuf::read(json_string); - std::cout << "OK" << std::endl << std::endl; -} -} // namespace test_string_unordered_map diff --git a/tests/flexbuffers/test_string_unordered_map.hpp b/tests/flexbuffers/test_string_unordered_map.hpp deleted file mode 100644 index 268057a3..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_tagged_union.cpp b/tests/flexbuffers/test_tagged_union.cpp index f09d141d..da123f2e 100644 --- a/tests/flexbuffers/test_tagged_union.cpp +++ b/tests/flexbuffers/test_tagged_union.cpp @@ -1,9 +1,6 @@ -#include "test_tagged_union.hpp" - #include #include #include -#include #include #include #include @@ -25,13 +22,10 @@ struct Square { double width; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>; +using Shapes = rfl::TaggedUnion<"shape", Circle, Square, Rectangle>; +TEST(flexbuf, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/flexbuffers/test_tagged_union.hpp b/tests/flexbuffers/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_timestamp.cpp b/tests/flexbuffers/test_timestamp.cpp new file mode 100644 index 00000000..1c1ce052 --- /dev/null +++ b/tests/flexbuffers/test_timestamp.cpp @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_timestamp { + +using TS = rfl::Timestamp<"%Y-%m-%d">; + +struct Person { + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + TS birthday; +}; + +TEST(flexbuf, test_timestamp) { + const auto result = TS::from_string("nonsense"); + + if (result) { + std::cout << "Failed: Expected an error, but got none." << std::endl; + return; + } + + const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19"}; + + write_and_read(bart); +} +} // namespace test_timestamp diff --git a/tests/flexbuffers/test_unique_ptr.cpp b/tests/flexbuffers/test_unique_ptr.cpp index c093a161..5adc14e9 100644 --- a/tests/flexbuffers/test_unique_ptr.cpp +++ b/tests/flexbuffers/test_unique_ptr.cpp @@ -1,9 +1,6 @@ -#include "test_unique_ptr.hpp" - #include #include #include -#include #include #include #include @@ -13,15 +10,12 @@ namespace test_unique_ptr { struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> children = - rfl::default_value; + rfl::Rename<"firstName", std::string> first_name; + rfl::Rename<"lastName", std::string> last_name = "Simpson"; + std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(flexbuf, 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/flexbuffers/test_unique_ptr.hpp b/tests/flexbuffers/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_unique_ptr2.cpp b/tests/flexbuffers/test_unique_ptr2.cpp index dd02f9b0..4a5b76f7 100644 --- a/tests/flexbuffers/test_unique_ptr2.cpp +++ b/tests/flexbuffers/test_unique_ptr2.cpp @@ -1,9 +1,6 @@ -#include "test_unique_ptr2.hpp" - #include #include #include -#include #include #include #include @@ -14,13 +11,15 @@ namespace test_unique_ptr2 { struct DecisionTree { struct Leaf { - rfl::Field<"value", double> value; + using Tag = rfl::Literal<"Leaf">; + double value; }; struct Node { - rfl::Field<"criticalValue", double> critical_value; - rfl::Field<"left", std::unique_ptr> lesser; - rfl::Field<"right", std::unique_ptr> greater; + using Tag = rfl::Literal<"Node">; + rfl::Rename<"criticalValue", double> critical_value; + std::unique_ptr lesser; + std::unique_ptr greater; }; using LeafOrNode = rfl::TaggedUnion<"type", Leaf, Node>; @@ -28,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(flexbuf, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/flexbuffers/test_unique_ptr2.hpp b/tests/flexbuffers/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_unordered_map.cpp b/tests/flexbuffers/test_unordered_map.cpp deleted file mode 100644 index f063937a..00000000 --- a/tests/flexbuffers/test_unordered_map.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "test_unordered_map.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_unordered_map { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> - children = rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - 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"})); - children->insert(std::make_pair(3, Person{.first_name = "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - // Unordered maps are unpredictable. We therefore only make sure that this - // compiles. - const auto json_string = rfl::flexbuf::write(homer); - const auto homer2 = rfl::flexbuf::read(json_string); - std::cout << "OK" << std::endl << std::endl; -} -} // namespace test_unordered_map diff --git a/tests/flexbuffers/test_unordered_map.hpp b/tests/flexbuffers/test_unordered_map.hpp deleted file mode 100644 index 9b059a96..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_unordered_multimap.cpp b/tests/flexbuffers/test_unordered_multimap.cpp deleted file mode 100644 index d304b26e..00000000 --- a/tests/flexbuffers/test_unordered_multimap.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "test_unordered_multimap.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_unordered_multimap { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> - children = rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - 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"})); - children->insert(std::make_pair(3, Person{.first_name = "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - // Unordered maps are unpredictable. We therefore only make sure that this - // compiles. - const auto json_string = rfl::flexbuf::write(homer); - const auto homer2 = rfl::flexbuf::read(json_string); - std::cout << "OK" << std::endl << std::endl; -} -} // namespace test_unordered_multimap diff --git a/tests/flexbuffers/test_unordered_multimap.hpp b/tests/flexbuffers/test_unordered_multimap.hpp deleted file mode 100644 index 0f36f705..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_unordered_multiset.cpp b/tests/flexbuffers/test_unordered_multiset.cpp deleted file mode 100644 index c72e2bc5..00000000 --- a/tests/flexbuffers/test_unordered_multiset.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "test_unordered_multiset.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_unordered_multiset { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> - children = rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - auto children = std::make_unique>( - std::unordered_multiset({"Bart", "Lisa", "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - // Unordered multisets are unpredictable. We therefore only make sure that - // this compiles. - const auto json_string = rfl::flexbuf::write(homer); - const auto homer2 = rfl::flexbuf::read(json_string); - std::cout << "OK" << std::endl << std::endl; -} -} // namespace test_unordered_multiset diff --git a/tests/flexbuffers/test_unordered_multiset.hpp b/tests/flexbuffers/test_unordered_multiset.hpp deleted file mode 100644 index 491ff7ba..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_unordered_set.cpp b/tests/flexbuffers/test_unordered_set.cpp deleted file mode 100644 index 1d9bbbf3..00000000 --- a/tests/flexbuffers/test_unordered_set.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "test_unordered_set.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_unordered_set { - -struct Person { - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name = "Simpson"; - rfl::Field<"children", std::unique_ptr>> - children = rfl::default_value; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - auto children = std::make_unique>( - std::unordered_set({"Bart", "Lisa", "Maggie"})); - - const auto homer = - Person{.first_name = "Homer", .children = std::move(children)}; - - // Unordered sets are unpredictable. We therefore only make sure that this - // compiles. - const auto json_string = rfl::flexbuf::write(homer); - const auto homer2 = rfl::flexbuf::read(json_string); - std::cout << "OK" << std::endl << std::endl; -} -} // namespace test_unordered_set diff --git a/tests/flexbuffers/test_unordered_set.hpp b/tests/flexbuffers/test_unordered_set.hpp deleted file mode 100644 index be2b257f..00000000 --- a/tests/flexbuffers/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/flexbuffers/test_variant.cpp b/tests/flexbuffers/test_variant.cpp index 2861a3ab..8adc8d80 100644 --- a/tests/flexbuffers/test_variant.cpp +++ b/tests/flexbuffers/test_variant.cpp @@ -1,9 +1,6 @@ -#include "test_variant.hpp" - #include #include #include -#include #include #include #include @@ -13,23 +10,21 @@ namespace test_variant { struct Circle { - rfl::Field<"radius", double> radius; + double radius; }; struct Rectangle { - rfl::Field<"height", double> height; - rfl::Field<"width", double> width; + double height; + double width; }; struct Square { - rfl::Field<"width", double> width; + double width; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - using Shapes = std::variant>; +using Shapes = std::variant>; +TEST(flexbuf, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/flexbuffers/test_variant.hpp b/tests/flexbuffers/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/flexbuffers/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/flexbuffers/test_wstring.cpp b/tests/flexbuffers/test_wstring.cpp index ba6202c0..e0e1dc1f 100644 --- a/tests/flexbuffers/test_wstring.cpp +++ b/tests/flexbuffers/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(flexbuf, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/flexbuffers/test_wstring.hpp b/tests/flexbuffers/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/flexbuffers/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/flexbuffers/tests.cpp b/tests/flexbuffers/tests.cpp deleted file mode 100644 index aab6d5a7..00000000 --- a/tests/flexbuffers/tests.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "test_all_of.hpp" -#include "test_anonymous_fields.hpp" -#include "test_box.hpp" -#include "test_custom_class1.hpp" -#include "test_custom_class2.hpp" -#include "test_custom_class3.hpp" -#include "test_custom_constructor.hpp" -#include "test_deque.hpp" -#include "test_field_variant.hpp" -#include "test_flatten_anonymous.hpp" -#include "test_forward_list.hpp" -#include "test_list.hpp" -#include "test_literal.hpp" -#include "test_map.hpp" -#include "test_monster_example1.hpp" -#include "test_monster_example2.hpp" -#include "test_multimap.hpp" -#include "test_multiset.hpp" -#include "test_optional_fields.hpp" -#include "test_readme_example.hpp" -#include "test_ref.hpp" -#include "test_save_load.hpp" -#include "test_set.hpp" -#include "test_string_map.hpp" -#include "test_string_unordered_map.hpp" -#include "test_tagged_union.hpp" -#include "test_unique_ptr.hpp" -#include "test_unique_ptr2.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_wstring.hpp" - -int main() { - test_readme_example::test(); - test_monster_example1::test(); - test_monster_example2::test(); - test_anonymous_fields::test(); - test_flatten_anonymous::test(); - test_optional_fields::test(); - test_unique_ptr::test(); - test_unique_ptr2::test(); - test_literal::test(); - test_variant::test(); - test_field_variant::test(); - test_tagged_union::test(); - test_custom_class1::test(); - test_custom_class2::test(); - test_custom_class3::test(); - test_box::test(); - test_ref::test(); - - test_deque::test(); - test_forward_list::test(); - test_list::test(); - test_map::test(); - test_multimap::test(); - test_multiset::test(); - test_set::test(); - test_string_map::test(); - test_string_unordered_map::test(); - test_unordered_map::test(); - test_unordered_multimap::test(); - test_unordered_multiset::test(); - test_unordered_set::test(); - - test_custom_constructor::test(); - - test_all_of::test(); - - test_save_load::test(); - test_wstring::test(); - - return 0; -} diff --git a/tests/flexbuffers/write_and_read.hpp b/tests/flexbuffers/write_and_read.hpp index 8bf426f3..a7f6d9ac 100644 --- a/tests/flexbuffers/write_and_read.hpp +++ b/tests/flexbuffers/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::flexbuf::write(_struct); - - const auto res = rfl::flexbuf::read(bytes1); - - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << std::endl; - return; - } - - const auto bytes2 = rfl::flexbuf::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::flexbuf::write(_struct); + const auto res = rfl::flexbuf::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::flexbuf::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/json/CMakeLists.txt b/tests/json/CMakeLists.txt index 1e077f6a..9ddfd6e0 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 + "${REFLECT_CPP_GTEST_LIB}" +) 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 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/toml/CMakeLists.txt b/tests/toml/CMakeLists.txt index c80c52fa..31763819 100644 --- a/tests/toml/CMakeLists.txt +++ b/tests/toml/CMakeLists.txt @@ -1,9 +1,18 @@ project(reflect-cpp-toml-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-toml-tests ${SOURCES}) +add_executable( + reflect-cpp-toml-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) target_include_directories(reflect-cpp-toml-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") -target_link_libraries(reflect-cpp-toml-tests PRIVATE reflectcpp) +target_link_libraries( + reflect-cpp-toml-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/toml/test_array.cpp b/tests/toml/test_array.cpp index f3f10206..421f2004 100644 --- a/tests/toml/test_array.cpp +++ b/tests/toml/test_array.cpp @@ -1,5 +1,3 @@ -#include "test_array.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include // Make sure things still compile when -// rfl.hpp is included after rfl/yaml.hpp. +// rfl.hpp is included after rfl/cbor.hpp. #include #include "write_and_read.hpp" @@ -21,9 +19,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(toml, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/toml/test_array.hpp b/tests/toml/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/toml/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_box.cpp b/tests/toml/test_box.cpp index 04d88641..b9a57c67 100644 --- a/tests/toml/test_box.cpp +++ b/tests/toml/test_box.cpp @@ -1,9 +1,6 @@ -#include "test_box.hpp" - #include #include #include -#include #include #include #include @@ -30,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(toml, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/toml/test_box.hpp b/tests/toml/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/toml/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_custom_class1.cpp b/tests/toml/test_custom_class1.cpp index 35f4a1da..1a020c27 100644 --- a/tests/toml/test_custom_class1.cpp +++ b/tests/toml/test_custom_class1.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class1.hpp" - #include #include #include -#include #include #include #include @@ -32,9 +29,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(toml, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/toml/test_custom_class1.hpp b/tests/toml/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/toml/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/toml/test_custom_class3.cpp b/tests/toml/test_custom_class3.cpp index 2ea105e4..c5f70a25 100644 --- a/tests/toml/test_custom_class3.cpp +++ b/tests/toml/test_custom_class3.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class3.hpp" - #include #include #include -#include #include #include #include @@ -57,9 +54,7 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(toml, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/toml/test_custom_class3.hpp b/tests/toml/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/toml/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/toml/test_custom_class4.cpp b/tests/toml/test_custom_class4.cpp index e2d79a94..fc3c009e 100644 --- a/tests/toml/test_custom_class4.cpp +++ b/tests/toml/test_custom_class4.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class4.hpp" - #include #include #include -#include #include #include #include @@ -58,9 +55,7 @@ struct Parser namespace test_custom_class4 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(toml, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/toml/test_custom_class4.hpp b/tests/toml/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/toml/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/toml/test_custom_constructor.cpp b/tests/toml/test_custom_constructor.cpp deleted file mode 100644 index 03123d2a..00000000 --- a/tests/toml/test_custom_constructor.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "test_custom_constructor.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_custom_constructor { - -struct Person { - static rfl::Result from_toml_obj( - typename rfl::toml::Reader::InputVarType _obj) { - /// This only exists for the purpose of the test. - const auto change_first_name = [](auto&& _person) { - return rfl::replace(std::move(_person), - rfl::Field<"firstName", std::string>("Bart")); - }; - const auto from_nt = [](auto&& _nt) { - return rfl::from_named_tuple(std::move(_nt)); - }; - return rfl::toml::read>(_obj) - .transform(from_nt) - .transform(change_first_name); - } - - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto res = rfl::toml::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; - } - - 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; - } -} -} // namespace test_custom_constructor diff --git a/tests/toml/test_custom_constructor.hpp b/tests/toml/test_custom_constructor.hpp deleted file mode 100644 index d3b5b950..00000000 --- a/tests/toml/test_custom_constructor.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_custom_constructor { -void test(); -} - diff --git a/tests/toml/test_default_values.cpp b/tests/toml/test_default_values.cpp index f6af2352..e5deb0af 100644 --- a/tests/toml/test_default_values.cpp +++ b/tests/toml/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(toml, 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/toml/test_default_values.hpp b/tests/toml/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/toml/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/toml/test_deque.cpp b/tests/toml/test_deque.cpp index 6dfa5803..d23c1e97 100644 --- a/tests/toml/test_deque.cpp +++ b/tests/toml/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(toml, 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/toml/test_deque.hpp b/tests/toml/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/toml/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_enum.cpp b/tests/toml/test_enum.cpp index d4d56a8b..e13df83f 100644 --- a/tests/toml/test_enum.cpp +++ b/tests/toml/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(toml, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/toml/test_enum.hpp b/tests/toml/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/toml/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/toml/test_field_variant.cpp b/tests/toml/test_field_variant.cpp index 8b17665f..e96360bf 100644 --- a/tests/toml/test_field_variant.cpp +++ b/tests/toml/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(toml, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/toml/test_field_variant.hpp b/tests/toml/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/toml/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/toml/test_flag_enum.cpp b/tests/toml/test_flag_enum.cpp index 1d3f76af..c0d5e8d2 100644 --- a/tests/toml/test_flag_enum.cpp +++ b/tests/toml/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(toml, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/toml/test_flag_enum.hpp b/tests/toml/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/toml/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/toml/test_flag_enum_with_int.cpp b/tests/toml/test_flag_enum_with_int.cpp index 4c7deefe..8a4fad20 100644 --- a/tests/toml/test_flag_enum_with_int.cpp +++ b/tests/toml/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(toml, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/toml/test_flag_enum_with_int.hpp b/tests/toml/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/toml/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/toml/test_flatten.cpp b/tests/toml/test_flatten.cpp index c7f1d9be..29a2c1d5 100644 --- a/tests/toml/test_flatten.cpp +++ b/tests/toml/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(toml, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/toml/test_flatten.hpp b/tests/toml/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/toml/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_flatten_anonymous.cpp b/tests/toml/test_flatten_anonymous.cpp index 05e61464..4b698c78 100644 --- a/tests/toml/test_flatten_anonymous.cpp +++ b/tests/toml/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(toml, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/toml/test_flatten_anonymous.hpp b/tests/toml/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/toml/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/toml/test_forward_list.cpp b/tests/toml/test_forward_list.cpp index dd8d9e56..da27ae84 100644 --- a/tests/toml/test_forward_list.cpp +++ b/tests/toml/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(toml, 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/toml/test_forward_list.hpp b/tests/toml/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/toml/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/toml/test_literal.cpp b/tests/toml/test_literal.cpp index 00578178..6d447c36 100644 --- a/tests/toml/test_literal.cpp +++ b/tests/toml/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(toml, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/toml/test_literal.hpp b/tests/toml/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/toml/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_literal_map.cpp b/tests/toml/test_literal_map.cpp index 9bbebafb..b07902f3 100644 --- a/tests/toml/test_literal_map.cpp +++ b/tests/toml/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(toml, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/toml/test_literal_map.hpp b/tests/toml/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/toml/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/toml/test_map.cpp b/tests/toml/test_map.cpp index e37ce564..774ccc61 100644 --- a/tests/toml/test_map.cpp +++ b/tests/toml/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(toml, 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/toml/test_map.hpp b/tests/toml/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/toml/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_map_with_key_validation.cpp b/tests/toml/test_map_with_key_validation.cpp index e758219d..0c27f830 100644 --- a/tests/toml/test_map_with_key_validation.cpp +++ b/tests/toml/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(toml, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/toml/test_map_with_key_validation.hpp b/tests/toml/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/toml/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/toml/test_monster_example.cpp b/tests/toml/test_monster_example.cpp index 052d8390..91446f7f 100644 --- a/tests/toml/test_monster_example.cpp +++ b/tests/toml/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(toml, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/toml/test_monster_example.hpp b/tests/toml/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/toml/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/toml/test_readme_example.cpp b/tests/toml/test_readme_example.cpp index 4e6f8ee0..970b8411 100644 --- a/tests/toml/test_readme_example.cpp +++ b/tests/toml/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(toml, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/toml/test_readme_example.hpp b/tests/toml/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/toml/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/toml/test_readme_example2.cpp b/tests/toml/test_readme_example2.cpp index a2d212a4..7ad06cad 100644 --- a/tests/toml/test_readme_example2.cpp +++ b/tests/toml/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(toml, test_readme_example2) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/toml/test_readme_example2.hpp b/tests/toml/test_readme_example2.hpp deleted file mode 100644 index 5c6b011c..00000000 --- a/tests/toml/test_readme_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example2 { -void test(); -} - diff --git a/tests/toml/test_ref.cpp b/tests/toml/test_ref.cpp index 32a32e6c..ebb254d5 100644 --- a/tests/toml/test_ref.cpp +++ b/tests/toml/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(toml, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/toml/test_ref.hpp b/tests/toml/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/toml/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_save_load.cpp b/tests/toml/test_save_load.cpp index fb14c76f..71faf284 100644 --- a/tests/toml/test_save_load.cpp +++ b/tests/toml/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(toml, 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::toml::write(homer1); const auto string2 = rfl::toml::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/toml/test_save_load.hpp b/tests/toml/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/toml/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/toml/test_set.cpp b/tests/toml/test_set.cpp index 9f2516ce..6a2f6ba3 100644 --- a/tests/toml/test_set.cpp +++ b/tests/toml/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(toml, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/toml/test_set.hpp b/tests/toml/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/toml/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_size.cpp b/tests/toml/test_size.cpp index c37b9bd8..19daf958 100644 --- a/tests/toml/test_size.cpp +++ b/tests/toml/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(toml, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/toml/test_size.hpp b/tests/toml/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/toml/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_string_map.cpp b/tests/toml/test_string_map.cpp index cb4fb903..cffd9293 100644 --- a/tests/toml/test_string_map.cpp +++ b/tests/toml/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(toml, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/toml/test_string_map.hpp b/tests/toml/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/toml/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/toml/test_tagged_union.cpp b/tests/toml/test_tagged_union.cpp index a9dd1abc..944aeaae 100644 --- a/tests/toml/test_tagged_union.cpp +++ b/tests/toml/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(toml, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/toml/test_tagged_union.hpp b/tests/toml/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/toml/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/toml/test_timestamp.cpp b/tests/toml/test_timestamp.cpp index 8af261d1..0eb12367 100644 --- a/tests/toml/test_timestamp.cpp +++ b/tests/toml/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(toml, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/toml/test_timestamp.hpp b/tests/toml/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/toml/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_unique_ptr.cpp b/tests/toml/test_unique_ptr.cpp index b1833533..ae2990ed 100644 --- a/tests/toml/test_unique_ptr.cpp +++ b/tests/toml/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(toml, 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/toml/test_unique_ptr.hpp b/tests/toml/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/toml/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/toml/test_unique_ptr2.cpp b/tests/toml/test_unique_ptr2.cpp index e3007267..ac32675e 100644 --- a/tests/toml/test_unique_ptr2.cpp +++ b/tests/toml/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(toml, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/toml/test_unique_ptr2.hpp b/tests/toml/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/toml/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/toml/test_variant.cpp b/tests/toml/test_variant.cpp index cc3d6cbe..087880ae 100644 --- a/tests/toml/test_variant.cpp +++ b/tests/toml/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(toml, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/toml/test_variant.hpp b/tests/toml/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/toml/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/toml/test_wstring.cpp b/tests/toml/test_wstring.cpp index ba6202c0..8c0c4f9a 100644 --- a/tests/toml/test_wstring.cpp +++ b/tests/toml/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(toml, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/toml/test_wstring.hpp b/tests/toml/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/toml/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/toml/tests.cpp b/tests/toml/tests.cpp deleted file mode 100644 index 7a38771d..00000000 --- a/tests/toml/tests.cpp +++ /dev/null @@ -1,69 +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_custom_constructor.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_custom_constructor::test(); - test_save_load::test(); - test_wstring::test(); - - return 0; -} diff --git a/tests/toml/write_and_read.hpp b/tests/toml/write_and_read.hpp index 8b0d7cac..4c45b5d5 100644 --- a/tests/toml/write_and_read.hpp +++ b/tests/toml/write_and_read.hpp @@ -1,32 +1,20 @@ #ifndef WRITE_AND_READ_ #define WRITE_AND_READ_ +#include + #include #include #include template void write_and_read(const T& _struct) { - const auto toml_string1 = rfl::toml::write(_struct); - const auto res = rfl::toml::read(toml_string1); - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << "Original string: " << toml_string1 << std::endl - << std::endl; - return; - } - const auto toml_string2 = rfl::toml::write(res.value()); - if (toml_string2 != toml_string1) { - std::cout << "Test failed on read. Expected:" << std::endl - << toml_string1 << std::endl - << "Got: " << std::endl - << toml_string2 << std::endl - << std::endl; - return; - } - // std::cout << toml_string1 << std::endl; - std::cout << "OK" << std::endl << std::endl; + const auto serialized1 = rfl::toml::write(_struct); + const auto res = rfl::toml::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::toml::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/xml/CMakeLists.txt b/tests/xml/CMakeLists.txt index c22bc116..fca21858 100644 --- a/tests/xml/CMakeLists.txt +++ b/tests/xml/CMakeLists.txt @@ -1,8 +1,18 @@ project(reflect-cpp-xml-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-xml-tests ${SOURCES}) +add_executable( + reflect-cpp-xml-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) -target_link_libraries(reflect-cpp-xml-tests PRIVATE reflectcpp) +target_include_directories(reflect-cpp-xml-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") +target_link_libraries( + reflect-cpp-xml-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) 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 diff --git a/tests/xml/test_array.cpp b/tests/xml/test_array.cpp index bcc21feb..60c0a58b 100644 --- a/tests/xml/test_array.cpp +++ b/tests/xml/test_array.cpp @@ -1,5 +1,3 @@ -#include "test_array.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include // Make sure things still compile when -// rfl.hpp is included after rfl/xml.hpp. +// rfl.hpp is included after rfl/cbor.hpp. #include #include "write_and_read.hpp" @@ -21,9 +19,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/xml/test_array.hpp b/tests/xml/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/xml/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_attributes.cpp b/tests/xml/test_attributes.cpp deleted file mode 100644 index 9e5e5931..00000000 --- a/tests/xml/test_attributes.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "test_attributes.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_attributes { - -using Age = rfl::Validator, rfl::Maximum<130>>; - -struct Person { - rfl::Rename<"firstName", rfl::Attribute> first_name; - rfl::Rename<"lastName", rfl::Attribute> last_name = "Simpson"; - rfl::Attribute town = "Springfield"; - rfl::Attribute> birthday; - rfl::Attribute age; - rfl::Attribute email; - std::vector child; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto bart = Person{.first_name = "Bart", - .birthday = "1987-04-19", - .age = 10, - .email = "bart@simpson.com"}; - - const auto lisa = Person{.first_name = "Lisa", - .birthday = "1987-04-19", - .age = 8, - .email = "lisa@simpson.com"}; - - const auto maggie = Person{.first_name = "Maggie", - .birthday = "1987-04-19", - .age = 0, - .email = "maggie@simpson.com"}; - - const auto homer = Person{.first_name = "Homer", - .birthday = "1987-04-19", - .age = 45, - .email = "homer@simpson.com", - .child = std::vector({bart, lisa, maggie})}; - - write_and_read(homer); -} -} // namespace test_attributes diff --git a/tests/xml/test_attributes.hpp b/tests/xml/test_attributes.hpp deleted file mode 100644 index e77be6af..00000000 --- a/tests/xml/test_attributes.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_attributes { -void test(); -} - diff --git a/tests/xml/test_box.cpp b/tests/xml/test_box.cpp index 04d88641..582c9004 100644 --- a/tests/xml/test_box.cpp +++ b/tests/xml/test_box.cpp @@ -1,9 +1,6 @@ -#include "test_box.hpp" - #include #include #include -#include #include #include #include @@ -30,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(xml, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/xml/test_box.hpp b/tests/xml/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/xml/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_custom_class1.cpp b/tests/xml/test_custom_class1.cpp index 35f4a1da..eee793eb 100644 --- a/tests/xml/test_custom_class1.cpp +++ b/tests/xml/test_custom_class1.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class1.hpp" - #include #include #include -#include #include #include #include @@ -32,9 +29,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/xml/test_custom_class1.hpp b/tests/xml/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/xml/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/xml/test_custom_class3.cpp b/tests/xml/test_custom_class3.cpp index 2ea105e4..3cbc23f6 100644 --- a/tests/xml/test_custom_class3.cpp +++ b/tests/xml/test_custom_class3.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class3.hpp" - #include #include #include -#include #include #include #include @@ -57,9 +54,7 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/xml/test_custom_class3.hpp b/tests/xml/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/xml/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/xml/test_custom_class4.cpp b/tests/xml/test_custom_class4.cpp index e2d79a94..55a5c693 100644 --- a/tests/xml/test_custom_class4.cpp +++ b/tests/xml/test_custom_class4.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class4.hpp" - #include #include #include -#include #include #include #include @@ -58,9 +55,7 @@ struct Parser namespace test_custom_class4 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/xml/test_custom_class4.hpp b/tests/xml/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/xml/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/xml/test_default_values.cpp b/tests/xml/test_default_values.cpp index 7613a6e3..d1220cc9 100644 --- a/tests/xml/test_default_values.cpp +++ b/tests/xml/test_default_values.cpp @@ -1,9 +1,6 @@ -#include "test_default_values.hpp" - #include #include #include -#include #include #include #include @@ -18,9 +15,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, 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/xml/test_default_values.hpp b/tests/xml/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/xml/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/xml/test_deque.cpp b/tests/xml/test_deque.cpp index cdcceac0..ede6a93f 100644 --- a/tests/xml/test_deque.cpp +++ b/tests/xml/test_deque.cpp @@ -1,8 +1,5 @@ -#include "test_deque.hpp" - #include #include -#include #include #include #include @@ -17,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, 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/xml/test_deque.hpp b/tests/xml/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/xml/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_enum.cpp b/tests/xml/test_enum.cpp index 0095ee19..0634b0eb 100644 --- a/tests/xml/test_enum.cpp +++ b/tests/xml/test_enum.cpp @@ -1,9 +1,6 @@ -#include "test_enum.hpp" - #include #include #include -#include #include #include #include @@ -19,9 +16,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/xml/test_enum.hpp b/tests/xml/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/xml/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/xml/test_field_variant.cpp b/tests/xml/test_field_variant.cpp index 114d000c..cd3adf8e 100644 --- a/tests/xml/test_field_variant.cpp +++ b/tests/xml/test_field_variant.cpp @@ -1,9 +1,6 @@ -#include "test_field_variant.hpp" - #include #include #include -#include #include #include #include @@ -29,12 +26,10 @@ 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(xml, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); - write_and_read<"shape">(r); + write_and_read<"root">(r); } } // namespace test_field_variant diff --git a/tests/xml/test_field_variant.hpp b/tests/xml/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/xml/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/xml/test_flag_enum.cpp b/tests/xml/test_flag_enum.cpp index 3846c1fd..d537322d 100644 --- a/tests/xml/test_flag_enum.cpp +++ b/tests/xml/test_flag_enum.cpp @@ -1,12 +1,10 @@ #include #include #include -#include #include #include #include -#include "test_enum.hpp" #include "write_and_read.hpp" namespace test_flag_enum { @@ -28,9 +26,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/xml/test_flag_enum.hpp b/tests/xml/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/xml/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/xml/test_flag_enum_with_int.cpp b/tests/xml/test_flag_enum_with_int.cpp index 4a0eb52d..7dcc7204 100644 --- a/tests/xml/test_flag_enum_with_int.cpp +++ b/tests/xml/test_flag_enum_with_int.cpp @@ -1,12 +1,10 @@ #include #include #include -#include #include #include #include -#include "test_enum.hpp" #include "write_and_read.hpp" namespace test_flag_enum_with_int { @@ -28,9 +26,7 @@ struct Circle { Color color; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/xml/test_flag_enum_with_int.hpp b/tests/xml/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/xml/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/xml/test_flatten.cpp b/tests/xml/test_flatten.cpp index 468add92..2d691656 100644 --- a/tests/xml/test_flatten.cpp +++ b/tests/xml/test_flatten.cpp @@ -1,9 +1,6 @@ -#include "test_flatten.hpp" - #include #include #include -#include #include #include #include @@ -24,9 +21,7 @@ struct Employee { rfl::Field<"salary", float> salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/xml/test_flatten.hpp b/tests/xml/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/xml/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_flatten_anonymous.cpp b/tests/xml/test_flatten_anonymous.cpp index c1bc0f07..6bfb6f00 100644 --- a/tests/xml/test_flatten_anonymous.cpp +++ b/tests/xml/test_flatten_anonymous.cpp @@ -1,9 +1,6 @@ -#include "test_flatten_anonymous.hpp" - #include #include #include -#include #include #include #include @@ -24,9 +21,7 @@ struct Employee { float salary; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/xml/test_flatten_anonymous.hpp b/tests/xml/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/xml/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/xml/test_forward_list.cpp b/tests/xml/test_forward_list.cpp index ed0d07b8..c8bf9a52 100644 --- a/tests/xml/test_forward_list.cpp +++ b/tests/xml/test_forward_list.cpp @@ -1,8 +1,5 @@ -#include "test_forward_list.hpp" - #include #include -#include #include #include #include @@ -17,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, 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/xml/test_forward_list.hpp b/tests/xml/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/xml/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/xml/test_literal.cpp b/tests/xml/test_literal.cpp index 9b940423..71c589e1 100644 --- a/tests/xml/test_literal.cpp +++ b/tests/xml/test_literal.cpp @@ -1,9 +1,6 @@ -#include "test_literal.hpp" - #include #include #include -#include #include #include #include @@ -21,9 +18,7 @@ struct Person { std::vector children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/xml/test_literal.hpp b/tests/xml/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/xml/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_literal_map.cpp b/tests/xml/test_literal_map.cpp index b9a03851..6f531efd 100644 --- a/tests/xml/test_literal_map.cpp +++ b/tests/xml/test_literal_map.cpp @@ -1,10 +1,7 @@ -#include "test_literal_map.hpp" - #include #include #include #include -#include #include #include #include @@ -15,15 +12,13 @@ namespace test_literal_map { using FieldName = rfl::Literal<"firstName", "lastName">; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); homer.insert(std::make_pair(FieldName::make<"lastName">(), std::make_unique("Simpson"))); - write_and_read<"person">(homer); + write_and_read<"root">(homer); } } // namespace test_literal_map diff --git a/tests/xml/test_literal_map.hpp b/tests/xml/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/xml/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/xml/test_map.cpp b/tests/xml/test_map.cpp index 3e897fe3..638a71e3 100644 --- a/tests/xml/test_map.cpp +++ b/tests/xml/test_map.cpp @@ -1,9 +1,6 @@ -#include "test_map.hpp" - #include #include #include -#include #include #include @@ -17,9 +14,7 @@ struct Person { std::map children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, 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/xml/test_map.hpp b/tests/xml/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/xml/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_map_with_key_validation.cpp b/tests/xml/test_map_with_key_validation.cpp index 20f831af..490665ad 100644 --- a/tests/xml/test_map_with_key_validation.cpp +++ b/tests/xml/test_map_with_key_validation.cpp @@ -1,9 +1,6 @@ -#include "test_map_with_key_validation.hpp" - #include #include #include -#include #include #include @@ -17,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/xml/test_map_with_key_validation.hpp b/tests/xml/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/xml/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/xml/test_monster_example.cpp b/tests/xml/test_monster_example.cpp index e9a443ad..b7003fc5 100644 --- a/tests/xml/test_monster_example.cpp +++ b/tests/xml/test_monster_example.cpp @@ -1,8 +1,5 @@ -#include "test_monster_example.hpp" - #include #include -#include #include #include #include @@ -32,16 +29,14 @@ struct Monster { short hp = 100; std::string name; bool friendly = false; - std::vector inventory; + std::vector inventory; Color color = Color::make<"Blue">(); std::vector weapons; Equipment equipped; std::vector path; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; @@ -49,8 +44,7 @@ void test() { const auto position = Vec3{1.0f, 2.0f, 3.0f}; - const auto inventory = - std::vector({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + const auto inventory = std::vector({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); const auto orc = Monster{.pos = position, .mana = 150, @@ -62,6 +56,5 @@ void test() { .equipped = rfl::make_field<"weapon">(axe)}; write_and_read(orc); - } } // namespace test_monster_example diff --git a/tests/xml/test_monster_example.hpp b/tests/xml/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/xml/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/xml/test_readme_example.cpp b/tests/xml/test_readme_example.cpp index f75b51ce..688d7182 100644 --- a/tests/xml/test_readme_example.cpp +++ b/tests/xml/test_readme_example.cpp @@ -1,8 +1,5 @@ -#include "test_readme_example.hpp" - #include #include -#include #include #include #include @@ -23,9 +20,7 @@ struct Person { std::vector child; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/xml/test_readme_example.hpp b/tests/xml/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/xml/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/xml/test_readme_example2.cpp b/tests/xml/test_readme_example2.cpp new file mode 100644 index 00000000..9468af5d --- /dev/null +++ b/tests/xml/test_readme_example2.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_readme_example2 { + +struct Person { + std::string first_name; + std::string last_name; + int age; +}; + +TEST(xml, test_readme_example2) { + const auto homer = + Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; + + write_and_read(homer); +} +} // namespace test_readme_example2 diff --git a/tests/xml/test_ref.cpp b/tests/xml/test_ref.cpp index 39a0c726..da6c8d5f 100644 --- a/tests/xml/test_ref.cpp +++ b/tests/xml/test_ref.cpp @@ -1,9 +1,6 @@ -#include "test_ref.hpp" - #include #include #include -#include #include #include #include @@ -30,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(xml, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/xml/test_ref.hpp b/tests/xml/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/xml/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_save_load.cpp b/tests/xml/test_save_load.cpp index 71adfcb3..a2ee4ad2 100644 --- a/tests/xml/test_save_load.cpp +++ b/tests/xml/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(xml, 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::xml::write(homer1); const auto string2 = rfl::xml::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/xml/test_save_load.hpp b/tests/xml/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/xml/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/xml/test_set.cpp b/tests/xml/test_set.cpp index fa135b37..2cea6dea 100644 --- a/tests/xml/test_set.cpp +++ b/tests/xml/test_set.cpp @@ -1,8 +1,5 @@ -#include "test_set.hpp" - #include #include -#include #include #include #include @@ -17,9 +14,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/xml/test_set.hpp b/tests/xml/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/xml/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_size.cpp b/tests/xml/test_size.cpp index d3f5d6cf..df0cbcfc 100644 --- a/tests/xml/test_size.cpp +++ b/tests/xml/test_size.cpp @@ -1,8 +1,5 @@ -#include "test_size.hpp" - #include #include -#include #include #include #include @@ -20,9 +17,7 @@ struct Person { children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/xml/test_size.hpp b/tests/xml/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/xml/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_string_map.cpp b/tests/xml/test_string_map.cpp index b4cd9e42..10fcb3ee 100644 --- a/tests/xml/test_string_map.cpp +++ b/tests/xml/test_string_map.cpp @@ -1,25 +1,20 @@ -#include "test_string_map.hpp" - #include #include #include #include -#include #include #include #include "write_and_read.hpp" namespace test_string_map { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); homer.insert( std::make_pair("lastName", std::make_unique("Simpson"))); - write_and_read<"person">(homer); + write_and_read<"root">(homer); } } // namespace test_string_map diff --git a/tests/xml/test_string_map.hpp b/tests/xml/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/xml/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/xml/test_tagged_union.cpp b/tests/xml/test_tagged_union.cpp index 21d0e20c..79ea0014 100644 --- a/tests/xml/test_tagged_union.cpp +++ b/tests/xml/test_tagged_union.cpp @@ -1,9 +1,6 @@ -#include "test_tagged_union.hpp" - #include #include #include -#include #include #include #include @@ -27,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(xml, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read<"root">(r); } } // namespace test_tagged_union diff --git a/tests/xml/test_tagged_union.hpp b/tests/xml/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/xml/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/xml/test_timestamp.cpp b/tests/xml/test_timestamp.cpp index da643b1e..1a0efaef 100644 --- a/tests/xml/test_timestamp.cpp +++ b/tests/xml/test_timestamp.cpp @@ -1,9 +1,6 @@ -#include "test_timestamp.hpp" - #include #include #include -#include #include #include #include @@ -20,9 +17,7 @@ struct Person { TS birthday; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/xml/test_timestamp.hpp b/tests/xml/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/xml/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_unique_ptr.cpp b/tests/xml/test_unique_ptr.cpp index 52c676cb..01f099fe 100644 --- a/tests/xml/test_unique_ptr.cpp +++ b/tests/xml/test_unique_ptr.cpp @@ -1,9 +1,6 @@ -#include "test_unique_ptr.hpp" - #include #include #include -#include #include #include #include @@ -18,9 +15,7 @@ struct Person { std::unique_ptr> children; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, 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/xml/test_unique_ptr.hpp b/tests/xml/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/xml/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/xml/test_unique_ptr2.cpp b/tests/xml/test_unique_ptr2.cpp index cd91ccb8..7efd891f 100644 --- a/tests/xml/test_unique_ptr2.cpp +++ b/tests/xml/test_unique_ptr2.cpp @@ -1,9 +1,6 @@ -#include "test_unique_ptr2.hpp" - #include #include #include -#include #include #include #include @@ -30,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(xml, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/xml/test_unique_ptr2.hpp b/tests/xml/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/xml/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/xml/test_variant.cpp b/tests/xml/test_variant.cpp index 49b9f041..bf64cdcb 100644 --- a/tests/xml/test_variant.cpp +++ b/tests/xml/test_variant.cpp @@ -1,9 +1,6 @@ -#include "test_variant.hpp" - #include #include #include -#include #include #include #include @@ -27,9 +24,7 @@ struct Square { using Shapes = std::variant>; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read<"root">(r); diff --git a/tests/xml/test_variant.hpp b/tests/xml/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/xml/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/xml/test_wstring.cpp b/tests/xml/test_wstring.cpp index 52499e4a..5cfbbe94 100644 --- a/tests/xml/test_wstring.cpp +++ b/tests/xml/test_wstring.cpp @@ -1,5 +1,3 @@ -#include "test_wstring.hpp" - #include #include #include @@ -9,18 +7,16 @@ #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(xml, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; - write_and_read<"root">(test); + write_and_read(test); } } // namespace test_wstring diff --git a/tests/xml/test_wstring.hpp b/tests/xml/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/xml/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/xml/test_xml_content.cpp b/tests/xml/test_xml_content.cpp index be011125..7e47c2bd 100644 --- a/tests/xml/test_xml_content.cpp +++ b/tests/xml/test_xml_content.cpp @@ -1,5 +1,3 @@ -#include "test_xml_content.hpp" - #include #include #include @@ -19,9 +17,7 @@ struct Person { std::vector child; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(xml, test_xml_content) { const auto bart = Person{.xml_content = "Bart Simpson", .birthday = "1987-04-19", .email = "bart@simpson.com"}; diff --git a/tests/xml/test_xml_content.hpp b/tests/xml/test_xml_content.hpp deleted file mode 100644 index 58b774fb..00000000 --- a/tests/xml/test_xml_content.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_xml_content { -void test(); -} - diff --git a/tests/xml/tests.cpp b/tests/xml/tests.cpp deleted file mode 100644 index f8671ee9..00000000 --- a/tests/xml/tests.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "test_array.hpp" -#include "test_attributes.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_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_xml_content.hpp" -#include "test_wstring.hpp" - -int main() { - test_readme_example::test(); - test_attributes::test(); - test_xml_content::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/xml/write_and_read.hpp b/tests/xml/write_and_read.hpp index ceb85c8a..a3aa4719 100644 --- a/tests/xml/write_and_read.hpp +++ b/tests/xml/write_and_read.hpp @@ -1,36 +1,23 @@ #ifndef WRITE_AND_READ_ #define WRITE_AND_READ_ +#include + #include +#include #include #include -#include "rfl/internal/StringLiteral.hpp" - template < rfl::internal::StringLiteral _root_name = rfl::internal::StringLiteral(""), class T> void write_and_read(const T& _struct) { - const auto xml_string1 = rfl::xml::write<_root_name>(_struct); - const auto res = rfl::xml::read(xml_string1); - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << "Original string: " << xml_string1 << std::endl - << std::endl; - return; - } - const auto xml_string2 = rfl::xml::write<_root_name>(res.value()); - if (xml_string2 != xml_string1) { - std::cout << "Test failed on read. Expected:" << std::endl - << xml_string1 << std::endl - << "Got: " << std::endl - << xml_string2 << std::endl - << std::endl; - return; - } - // std::cout << xml_string1 << std::endl; - std::cout << "OK" << std::endl << std::endl; + const auto serialized1 = rfl::xml::write<_root_name>(_struct); + const auto res = rfl::xml::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::xml::write<_root_name>(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/tests/yaml/CMakeLists.txt b/tests/yaml/CMakeLists.txt index 238ef474..5445171a 100644 --- a/tests/yaml/CMakeLists.txt +++ b/tests/yaml/CMakeLists.txt @@ -1,8 +1,18 @@ project(reflect-cpp-yaml-tests) -file(GLOB_RECURSE SOURCES "*.cpp") +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cpp") -add_executable(reflect-cpp-yaml-tests ${SOURCES}) +add_executable( + reflect-cpp-yaml-tests + ${SOURCES} + "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/src/gtest_main.cc" +) -target_link_libraries(reflect-cpp-yaml-tests PRIVATE reflectcpp) +target_include_directories(reflect-cpp-yaml-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") +target_link_libraries( + reflect-cpp-yaml-tests + PRIVATE + reflectcpp + "${REFLECT_CPP_GTEST_LIB}" +) diff --git a/tests/yaml/test_array.cpp b/tests/yaml/test_array.cpp index a4586d3b..713a52b0 100644 --- a/tests/yaml/test_array.cpp +++ b/tests/yaml/test_array.cpp @@ -1,5 +1,3 @@ -#include "test_array.hpp" - #include #include #include @@ -8,7 +6,7 @@ #include // Make sure things still compile when -// rfl.hpp is included after rfl/yaml.hpp. +// rfl.hpp is included after rfl/cbor.hpp. #include #include "write_and_read.hpp" @@ -21,9 +19,7 @@ struct Person { std::unique_ptr> children = nullptr; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(yaml, test_array) { auto bart = Person{.first_name = "Bart"}; auto lisa = Person{.first_name = "Lisa"}; diff --git a/tests/yaml/test_array.hpp b/tests/yaml/test_array.hpp deleted file mode 100644 index 502c3388..00000000 --- a/tests/yaml/test_array.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_array{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_box.cpp b/tests/yaml/test_box.cpp index 04d88641..ca6e0cfe 100644 --- a/tests/yaml/test_box.cpp +++ b/tests/yaml/test_box.cpp @@ -1,9 +1,6 @@ -#include "test_box.hpp" - #include #include #include -#include #include #include #include @@ -30,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(yaml, test_box) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/yaml/test_box.hpp b/tests/yaml/test_box.hpp deleted file mode 100644 index a564b9e1..00000000 --- a/tests/yaml/test_box.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_box{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_custom_class1.cpp b/tests/yaml/test_custom_class1.cpp index 35f4a1da..872d1ef7 100644 --- a/tests/yaml/test_custom_class1.cpp +++ b/tests/yaml/test_custom_class1.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class1.hpp" - #include #include #include -#include #include #include #include @@ -32,9 +29,7 @@ struct Person { PersonImpl impl; }; -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(yaml, test_custom_class1) { const auto bart = Person("Bart"); write_and_read(bart); diff --git a/tests/yaml/test_custom_class1.hpp b/tests/yaml/test_custom_class1.hpp deleted file mode 100644 index eafe6cd0..00000000 --- a/tests/yaml/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/yaml/test_custom_class3.cpp b/tests/yaml/test_custom_class3.cpp index 2ea105e4..a59d5c22 100644 --- a/tests/yaml/test_custom_class3.cpp +++ b/tests/yaml/test_custom_class3.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class3.hpp" - #include #include #include -#include #include #include #include @@ -57,9 +54,7 @@ struct Parser namespace test_custom_class3 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(yaml, test_custom_class3) { const auto bart = Person("Bart", "Simpson", 10); write_and_read(bart); diff --git a/tests/yaml/test_custom_class3.hpp b/tests/yaml/test_custom_class3.hpp deleted file mode 100644 index 9a6fdab4..00000000 --- a/tests/yaml/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/yaml/test_custom_class4.cpp b/tests/yaml/test_custom_class4.cpp index e2d79a94..43bccf9f 100644 --- a/tests/yaml/test_custom_class4.cpp +++ b/tests/yaml/test_custom_class4.cpp @@ -1,9 +1,6 @@ -#include "test_custom_class4.hpp" - #include #include #include -#include #include #include #include @@ -58,9 +55,7 @@ struct Parser namespace test_custom_class4 { -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - +TEST(yaml, test_custom_class4) { const auto bart = test_custom_class4::Person( "Bart", rfl::make_box("Simpson"), 10); diff --git a/tests/yaml/test_custom_class4.hpp b/tests/yaml/test_custom_class4.hpp deleted file mode 100644 index 2d3b151a..00000000 --- a/tests/yaml/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/yaml/test_custom_constructor.cpp b/tests/yaml/test_custom_constructor.cpp deleted file mode 100644 index 3bff855c..00000000 --- a/tests/yaml/test_custom_constructor.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "test_custom_constructor.hpp" - -#include -#include -#include -#include -#include -#include - -#include "write_and_read.hpp" - -namespace test_custom_constructor { - -struct Person { - static rfl::Result from_yaml_obj( - typename rfl::yaml::Reader::InputVarType _obj) { - /// This only exists for the purpose of the test. - const auto change_first_name = [](auto&& _person) { - return rfl::replace(std::move(_person), - rfl::Field<"firstName", std::string>("Bart")); - }; - const auto from_nt = [](auto&& _nt) { - return rfl::from_named_tuple(std::move(_nt)); - }; - return rfl::yaml::read>(_obj) - .transform(from_nt) - .transform(change_first_name); - } - - rfl::Field<"firstName", std::string> first_name; - rfl::Field<"lastName", std::string> last_name; - rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday; -}; - -void test() { - std::cout << std::source_location::current().function_name() << std::endl; - - const auto res = rfl::yaml::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; - } - - 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; - } -} -} // namespace test_custom_constructor diff --git a/tests/yaml/test_custom_constructor.hpp b/tests/yaml/test_custom_constructor.hpp deleted file mode 100644 index 013721d0..00000000 --- a/tests/yaml/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/yaml/test_default_values.cpp b/tests/yaml/test_default_values.cpp index f6af2352..d73fad6b 100644 --- a/tests/yaml/test_default_values.cpp +++ b/tests/yaml/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(yaml, 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/yaml/test_default_values.hpp b/tests/yaml/test_default_values.hpp deleted file mode 100644 index c8f8360e..00000000 --- a/tests/yaml/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/yaml/test_deque.cpp b/tests/yaml/test_deque.cpp index 6dfa5803..6e0404c2 100644 --- a/tests/yaml/test_deque.cpp +++ b/tests/yaml/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(yaml, 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/yaml/test_deque.hpp b/tests/yaml/test_deque.hpp deleted file mode 100644 index 6781e880..00000000 --- a/tests/yaml/test_deque.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_deque{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_enum.cpp b/tests/yaml/test_enum.cpp index d4d56a8b..9a37b856 100644 --- a/tests/yaml/test_enum.cpp +++ b/tests/yaml/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(yaml, test_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::green}; write_and_read(circle); diff --git a/tests/yaml/test_enum.hpp b/tests/yaml/test_enum.hpp deleted file mode 100644 index 2e2e0b3d..00000000 --- a/tests/yaml/test_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_enum { -void test(); -} - diff --git a/tests/yaml/test_field_variant.cpp b/tests/yaml/test_field_variant.cpp index 8b17665f..c75be2d1 100644 --- a/tests/yaml/test_field_variant.cpp +++ b/tests/yaml/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(yaml, test_field_variant) { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); diff --git a/tests/yaml/test_field_variant.hpp b/tests/yaml/test_field_variant.hpp deleted file mode 100644 index ba93e732..00000000 --- a/tests/yaml/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/yaml/test_flag_enum.cpp b/tests/yaml/test_flag_enum.cpp index 1d3f76af..6c14a1db 100644 --- a/tests/yaml/test_flag_enum.cpp +++ b/tests/yaml/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(yaml, test_flag_enum) { const auto circle = Circle{.radius = 2.0, .color = Color::blue | Color::orange}; diff --git a/tests/yaml/test_flag_enum.hpp b/tests/yaml/test_flag_enum.hpp deleted file mode 100644 index 2f4dc7a0..00000000 --- a/tests/yaml/test_flag_enum.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum { -void test(); -} - diff --git a/tests/yaml/test_flag_enum_with_int.cpp b/tests/yaml/test_flag_enum_with_int.cpp index 4c7deefe..5f63353c 100644 --- a/tests/yaml/test_flag_enum_with_int.cpp +++ b/tests/yaml/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(yaml, test_flag_enum_with_int) { const auto circle = Circle{.radius = 2.0, .color = static_cast(10000)}; write_and_read(circle); diff --git a/tests/yaml/test_flag_enum_with_int.hpp b/tests/yaml/test_flag_enum_with_int.hpp deleted file mode 100644 index a7512b60..00000000 --- a/tests/yaml/test_flag_enum_with_int.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flag_enum_with_int { -void test(); -} - diff --git a/tests/yaml/test_flatten.cpp b/tests/yaml/test_flatten.cpp index c7f1d9be..40a7ed56 100644 --- a/tests/yaml/test_flatten.cpp +++ b/tests/yaml/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(yaml, test_flatten) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/yaml/test_flatten.hpp b/tests/yaml/test_flatten.hpp deleted file mode 100644 index 24d60e11..00000000 --- a/tests/yaml/test_flatten.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_flatten{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_flatten_anonymous.cpp b/tests/yaml/test_flatten_anonymous.cpp index 05e61464..866c80ae 100644 --- a/tests/yaml/test_flatten_anonymous.cpp +++ b/tests/yaml/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(yaml, test_flatten_anonymous) { const auto employee = Employee{ .person = Person{.first_name = "Homer", .last_name = rfl::make_box("Simpson"), diff --git a/tests/yaml/test_flatten_anonymous.hpp b/tests/yaml/test_flatten_anonymous.hpp deleted file mode 100644 index 7ffa2785..00000000 --- a/tests/yaml/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/yaml/test_forward_list.cpp b/tests/yaml/test_forward_list.cpp index dd8d9e56..6b8b5eb8 100644 --- a/tests/yaml/test_forward_list.cpp +++ b/tests/yaml/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(yaml, 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/yaml/test_forward_list.hpp b/tests/yaml/test_forward_list.hpp deleted file mode 100644 index 9784a0c4..00000000 --- a/tests/yaml/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/yaml/test_literal.cpp b/tests/yaml/test_literal.cpp index 00578178..7c5f7e50 100644 --- a/tests/yaml/test_literal.cpp +++ b/tests/yaml/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(yaml, test_literal) { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read(bart); diff --git a/tests/yaml/test_literal.hpp b/tests/yaml/test_literal.hpp deleted file mode 100644 index ccd500ef..00000000 --- a/tests/yaml/test_literal.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_literal{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_literal_map.cpp b/tests/yaml/test_literal_map.cpp index 9bbebafb..41b4dffc 100644 --- a/tests/yaml/test_literal_map.cpp +++ b/tests/yaml/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(yaml, test_literal_map) { std::map> homer; homer.insert(std::make_pair(FieldName::make<"firstName">(), std::make_unique("Homer"))); diff --git a/tests/yaml/test_literal_map.hpp b/tests/yaml/test_literal_map.hpp deleted file mode 100644 index cc05d0c8..00000000 --- a/tests/yaml/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/yaml/test_map.cpp b/tests/yaml/test_map.cpp index e37ce564..68c63646 100644 --- a/tests/yaml/test_map.cpp +++ b/tests/yaml/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(yaml, 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/yaml/test_map.hpp b/tests/yaml/test_map.hpp deleted file mode 100644 index 9ae49728..00000000 --- a/tests/yaml/test_map.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_map{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_map_with_key_validation.cpp b/tests/yaml/test_map_with_key_validation.cpp index e758219d..6cde9a83 100644 --- a/tests/yaml/test_map_with_key_validation.cpp +++ b/tests/yaml/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(yaml, test_map_with_key_validation) { auto children = std::make_unique>(); children->insert(std::make_pair("Bart", Person{.first_name = "Bart"})); diff --git a/tests/yaml/test_map_with_key_validation.hpp b/tests/yaml/test_map_with_key_validation.hpp deleted file mode 100644 index 1372f926..00000000 --- a/tests/yaml/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/yaml/test_monster_example.cpp b/tests/yaml/test_monster_example.cpp index 052d8390..9f6f81b2 100644 --- a/tests/yaml/test_monster_example.cpp +++ b/tests/yaml/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(yaml, test_monster_example) { const auto sword = Weapon{.name = "Sword", .damage = 3}; const auto axe = Weapon{.name = "Axe", .damage = 5}; diff --git a/tests/yaml/test_monster_example.hpp b/tests/yaml/test_monster_example.hpp deleted file mode 100644 index f2d959fc..00000000 --- a/tests/yaml/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/yaml/test_readme_example.cpp b/tests/yaml/test_readme_example.cpp index 4e6f8ee0..a877b3eb 100644 --- a/tests/yaml/test_readme_example.cpp +++ b/tests/yaml/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(yaml, test_readme_example) { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19", .age = 10, diff --git a/tests/yaml/test_readme_example.hpp b/tests/yaml/test_readme_example.hpp deleted file mode 100644 index 68c6cf81..00000000 --- a/tests/yaml/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/yaml/test_readme_example2.cpp b/tests/yaml/test_readme_example2.cpp index a2d212a4..e42ac269 100644 --- a/tests/yaml/test_readme_example2.cpp +++ b/tests/yaml/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(yaml, test_readme_example2) { const auto homer = Person{.first_name = "Homer", .last_name = "Simpson", .age = 45}; diff --git a/tests/yaml/test_readme_example2.hpp b/tests/yaml/test_readme_example2.hpp deleted file mode 100644 index 5c6b011c..00000000 --- a/tests/yaml/test_readme_example2.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_readme_example2 { -void test(); -} - diff --git a/tests/yaml/test_ref.cpp b/tests/yaml/test_ref.cpp index 32a32e6c..93d069d7 100644 --- a/tests/yaml/test_ref.cpp +++ b/tests/yaml/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(yaml, test_ref) { const auto leaf1 = DecisionTree::Leaf{.value = 3.0}; const auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/yaml/test_ref.hpp b/tests/yaml/test_ref.hpp deleted file mode 100644 index d289ba09..00000000 --- a/tests/yaml/test_ref.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_ref{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_save_load.cpp b/tests/yaml/test_save_load.cpp index c20fc181..ac656f0b 100644 --- a/tests/yaml/test_save_load.cpp +++ b/tests/yaml/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(yaml, 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::yaml::write(homer1); const auto string2 = rfl::yaml::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/yaml/test_save_load.hpp b/tests/yaml/test_save_load.hpp deleted file mode 100644 index 7bf10359..00000000 --- a/tests/yaml/test_save_load.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_save_load { -void test(); -} - diff --git a/tests/yaml/test_set.cpp b/tests/yaml/test_set.cpp index 9f2516ce..0f19fbcd 100644 --- a/tests/yaml/test_set.cpp +++ b/tests/yaml/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(yaml, test_set) { auto children = std::make_unique>( std::set({"Bart", "Lisa", "Maggie"})); diff --git a/tests/yaml/test_set.hpp b/tests/yaml/test_set.hpp deleted file mode 100644 index 142a663b..00000000 --- a/tests/yaml/test_set.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_set{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_size.cpp b/tests/yaml/test_size.cpp index c37b9bd8..b3502ff4 100644 --- a/tests/yaml/test_size.cpp +++ b/tests/yaml/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(yaml, test_size) { const auto bart = Person{ .first_name = "Bart", .last_name = "Simpson", .birthday = "1987-04-19"}; diff --git a/tests/yaml/test_size.hpp b/tests/yaml/test_size.hpp deleted file mode 100644 index be330df0..00000000 --- a/tests/yaml/test_size.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_size{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_string_map.cpp b/tests/yaml/test_string_map.cpp index cb4fb903..fe682d62 100644 --- a/tests/yaml/test_string_map.cpp +++ b/tests/yaml/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(yaml, test_string_map) { std::map> homer; homer.insert( std::make_pair("firstName", std::make_unique("Homer"))); diff --git a/tests/yaml/test_string_map.hpp b/tests/yaml/test_string_map.hpp deleted file mode 100644 index 94cb975a..00000000 --- a/tests/yaml/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/yaml/test_tagged_union.cpp b/tests/yaml/test_tagged_union.cpp index a9dd1abc..b226f2e6 100644 --- a/tests/yaml/test_tagged_union.cpp +++ b/tests/yaml/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(yaml, test_tagged_union) { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r); } } // namespace test_tagged_union diff --git a/tests/yaml/test_tagged_union.hpp b/tests/yaml/test_tagged_union.hpp deleted file mode 100644 index 5d522ff9..00000000 --- a/tests/yaml/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/yaml/test_timestamp.cpp b/tests/yaml/test_timestamp.cpp index 8af261d1..64e3bdce 100644 --- a/tests/yaml/test_timestamp.cpp +++ b/tests/yaml/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(yaml, test_timestamp) { const auto result = TS::from_string("nonsense"); if (result) { diff --git a/tests/yaml/test_timestamp.hpp b/tests/yaml/test_timestamp.hpp deleted file mode 100644 index 891d89b9..00000000 --- a/tests/yaml/test_timestamp.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_timestamp{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_unique_ptr.cpp b/tests/yaml/test_unique_ptr.cpp index b1833533..35d74cc3 100644 --- a/tests/yaml/test_unique_ptr.cpp +++ b/tests/yaml/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(yaml, 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/yaml/test_unique_ptr.hpp b/tests/yaml/test_unique_ptr.hpp deleted file mode 100644 index 428ea2a2..00000000 --- a/tests/yaml/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/yaml/test_unique_ptr2.cpp b/tests/yaml/test_unique_ptr2.cpp index e3007267..3a8ee94a 100644 --- a/tests/yaml/test_unique_ptr2.cpp +++ b/tests/yaml/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(yaml, test_unique_ptr2) { auto leaf1 = DecisionTree::Leaf{.value = 3.0}; auto leaf2 = DecisionTree::Leaf{.value = 5.0}; diff --git a/tests/yaml/test_unique_ptr2.hpp b/tests/yaml/test_unique_ptr2.hpp deleted file mode 100644 index 74adc170..00000000 --- a/tests/yaml/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/yaml/test_variant.cpp b/tests/yaml/test_variant.cpp index cc3d6cbe..e9bc0c9a 100644 --- a/tests/yaml/test_variant.cpp +++ b/tests/yaml/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(yaml, test_variant) { const Shapes r = Rectangle{.height = 10, .width = 5}; write_and_read(r); diff --git a/tests/yaml/test_variant.hpp b/tests/yaml/test_variant.hpp deleted file mode 100644 index 0e58ce71..00000000 --- a/tests/yaml/test_variant.hpp +++ /dev/null @@ -1,4 +0,0 @@ -namespace test_variant{ - void test(); -} - \ No newline at end of file diff --git a/tests/yaml/test_wstring.cpp b/tests/yaml/test_wstring.cpp index ba6202c0..5fadc26c 100644 --- a/tests/yaml/test_wstring.cpp +++ b/tests/yaml/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(yaml, test_wstring) { + const auto test = TestStruct{.theNormalString = "The normal string", + .theWiderString = L"The wider string"}; write_and_read(test); } diff --git a/tests/yaml/test_wstring.hpp b/tests/yaml/test_wstring.hpp deleted file mode 100644 index 0f93e784..00000000 --- a/tests/yaml/test_wstring.hpp +++ /dev/null @@ -1,3 +0,0 @@ -namespace test_wstring { - void test(); -} diff --git a/tests/yaml/tests.cpp b/tests/yaml/tests.cpp deleted file mode 100644 index 7a38771d..00000000 --- a/tests/yaml/tests.cpp +++ /dev/null @@ -1,69 +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_custom_constructor.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_custom_constructor::test(); - test_save_load::test(); - test_wstring::test(); - - return 0; -} diff --git a/tests/yaml/write_and_read.hpp b/tests/yaml/write_and_read.hpp index 6f6e2743..6e4d5922 100644 --- a/tests/yaml/write_and_read.hpp +++ b/tests/yaml/write_and_read.hpp @@ -1,32 +1,20 @@ #ifndef WRITE_AND_READ_ #define WRITE_AND_READ_ +#include + #include #include #include template void write_and_read(const T& _struct) { - const auto yaml_string1 = rfl::yaml::write(_struct); - const auto res = rfl::yaml::read(yaml_string1); - if (!res) { - std::cout << "Test failed on read. Error: " << res.error().value().what() - << std::endl - << "Original string: " << yaml_string1 << std::endl - << std::endl; - return; - } - const auto yaml_string2 = rfl::yaml::write(res.value()); - if (yaml_string2 != yaml_string1) { - std::cout << "Test failed on read. Expected:" << std::endl - << yaml_string1 << std::endl - << "Got: " << std::endl - << yaml_string2 << std::endl - << std::endl; - return; - } - // std::cout << yaml_string1 << std::endl; - std::cout << "OK" << std::endl << std::endl; + const auto serialized1 = rfl::yaml::write(_struct); + const auto res = rfl::yaml::read(serialized1); + EXPECT_TRUE(res && true) << "Test failed on read. Error: " + << res.error().value().what(); + const auto serialized2 = rfl::yaml::write(res.value()); + EXPECT_EQ(serialized1, serialized2); } #endif diff --git a/vcpkg.json b/vcpkg.json index 625ac896..7beb0dfe 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -31,6 +31,10 @@ "name": "yaml-cpp", "version>=": "0.8.0#1" }, + { + "name": "gtest", + "version>=": "1.14.0" + }, { "name": "vcpkg-cmake", "version>=": "2023-05-04"