From 499011c8badf0f93f701669457ad6844aa169941 Mon Sep 17 00:00:00 2001 From: Patrick Urbanke Date: Sat, 7 Oct 2023 12:42:06 +0200 Subject: [PATCH] Use R-strings for the tests --- tests/test_box.hpp | 4 +--- tests/test_custom_class1.hpp | 3 +-- tests/test_custom_class3.hpp | 4 ++-- tests/test_default_values.hpp | 5 +---- tests/test_field_variant.hpp | 2 +- tests/test_literal.hpp | 3 +-- tests/test_optional_fields.hpp | 5 +---- tests/test_readme_example.hpp | 7 +------ tests/test_ref.hpp | 4 +--- tests/test_tagged_union.hpp | 3 +-- tests/test_timestamp.hpp | 6 +++--- tests/test_unique_ptr.hpp | 5 +---- tests/test_unique_ptr2.hpp | 4 +--- tests/test_variant.hpp | 2 +- 14 files changed, 17 insertions(+), 40 deletions(-) diff --git a/tests/test_box.hpp b/tests/test_box.hpp index 6d7d4f93..1ff2730c 100644 --- a/tests/test_box.hpp +++ b/tests/test_box.hpp @@ -41,7 +41,5 @@ void test_box() { write_and_read( tree, - "{\"leafOrNode\":{\"type\":\"Node\",\"criticalValue\":10.0,\"left\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":3.0}},\"right\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":5.0}}}}"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } diff --git a/tests/test_custom_class1.hpp b/tests/test_custom_class1.hpp index dc3924b6..42670065 100644 --- a/tests/test_custom_class1.hpp +++ b/tests/test_custom_class1.hpp @@ -34,6 +34,5 @@ void test_custom_class1() { const auto bart = Person("Bart"); write_and_read( - bart, - "{\"firstName\":\"Bart\",\"lastName\":\"Simpson\",\"children\":[]}"); + bart, R"({"firstName":"Bart","lastName":"Simpson","children":[]})"); } diff --git a/tests/test_custom_class3.hpp b/tests/test_custom_class3.hpp index 5ba99bb7..6f3b00d7 100644 --- a/tests/test_custom_class3.hpp +++ b/tests/test_custom_class3.hpp @@ -58,6 +58,6 @@ void test_custom_class3() { const auto bart = tcc3::Person("Bart", "Simpson", 10); - write_and_read( - bart, "{\"firstName\":\"Bart\",\"lastName\":\"Simpson\",\"age\":10}"); + write_and_read(bart, + R"({"firstName":"Bart","lastName":"Simpson","age":10})"); } diff --git a/tests/test_default_values.hpp b/tests/test_default_values.hpp index 6348f0ba..33fd0799 100644 --- a/tests/test_default_values.hpp +++ b/tests/test_default_values.hpp @@ -27,8 +27,5 @@ void test_default_values() { write_and_read( homer, - "{\"firstName\":\"Homer\",\"lastName\":\"Simpson\",\"children\":[{" - "\"firstName\":\"Bart\",\"lastName\":\"Simpson\",\"children\":[]},{" - "\"firstName\":\"Lisa\",\"lastName\":\"Simpson\",\"children\":[]},{" - "\"firstName\":\"Maggie\",\"lastName\":\"Simpson\",\"children\":[]}]}"); + R"({"firstName":"Homer","lastName":"Simpson","children":[{"firstName":"Bart","lastName":"Simpson","children":[]},{"firstName":"Lisa","lastName":"Simpson","children":[]},{"firstName":"Maggie","lastName":"Simpson","children":[]}]})"); } diff --git a/tests/test_field_variant.hpp b/tests/test_field_variant.hpp index f449533b..4dfb5e49 100644 --- a/tests/test_field_variant.hpp +++ b/tests/test_field_variant.hpp @@ -30,5 +30,5 @@ void test_field_variant() { const Shapes r = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); - write_and_read(r, "{\"rectangle\":{\"height\":10.0,\"width\":5.0}}"); + write_and_read(r, R"({"rectangle":{"height":10.0,"width":5.0}})"); } diff --git a/tests/test_literal.hpp b/tests/test_literal.hpp index 425af72d..920b281d 100644 --- a/tests/test_literal.hpp +++ b/tests/test_literal.hpp @@ -24,6 +24,5 @@ void test_literal() { const auto bart = Person{.first_name = FirstName::make<"Bart">()}; write_and_read( - bart, - "{\"firstName\":\"Bart\",\"lastName\":\"Simpson\",\"children\":[]}"); + bart, R"({"firstName":"Bart","lastName":"Simpson","children":[]})"); } diff --git a/tests/test_optional_fields.hpp b/tests/test_optional_fields.hpp index 360724e2..4d27a15d 100644 --- a/tests/test_optional_fields.hpp +++ b/tests/test_optional_fields.hpp @@ -28,8 +28,5 @@ void test_optional_fields() { write_and_read( homer, - "{\"firstName\":\"Homer\",\"lastName\":\"Simpson\",\"children\":[{" - "\"firstName\":\"Bart\",\"lastName\":\"Simpson\"},{" - "\"firstName\":\"Lisa\",\"lastName\":\"Simpson\"},{" - "\"firstName\":\"Maggie\",\"lastName\":\"Simpson\"}]}"); + R"({"firstName":"Homer","lastName":"Simpson","children":[{"firstName":"Bart","lastName":"Simpson"},{"firstName":"Lisa","lastName":"Simpson"},{"firstName":"Maggie","lastName":"Simpson"}]})"); } diff --git a/tests/test_readme_example.hpp b/tests/test_readme_example.hpp index 345e15bd..417d9d7c 100644 --- a/tests/test_readme_example.hpp +++ b/tests/test_readme_example.hpp @@ -47,10 +47,5 @@ void test_readme_example() { write_and_read( homer, - "{\"firstName\":\"Homer\",\"lastName\":\"Simpson\",\"birthday\":\"1987-" - "04-19\",\"children\":[{\"firstName\":\"Bart\",\"lastName\":" - "\"Simpson\",\"birthday\":\"1987-04-19\",\"children\":[]},{" - "\"firstName\":\"Lisa\",\"lastName\":\"Simpson\",\"birthday\":\"1987-" - "04-19\",\"children\":[]},{\"firstName\":\"Maggie\",\"lastName\":" - "\"Simpson\",\"birthday\":\"1987-04-19\",\"children\":[]}]}"); + R"({"firstName":"Homer","lastName":"Simpson","birthday":"1987-04-19","children":[{"firstName":"Bart","lastName":"Simpson","birthday":"1987-04-19","children":[]},{"firstName":"Lisa","lastName":"Simpson","birthday":"1987-04-19","children":[]},{"firstName":"Maggie","lastName":"Simpson","birthday":"1987-04-19","children":[]}]})"); } diff --git a/tests/test_ref.hpp b/tests/test_ref.hpp index 8f1fb894..8c353f5d 100644 --- a/tests/test_ref.hpp +++ b/tests/test_ref.hpp @@ -41,7 +41,5 @@ void test_ref() { write_and_read( tree, - "{\"leafOrNode\":{\"type\":\"Node\",\"criticalValue\":10.0,\"left\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":3.0}},\"right\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":5.0}}}}"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } diff --git a/tests/test_tagged_union.hpp b/tests/test_tagged_union.hpp index 016aaabe..aa59f398 100644 --- a/tests/test_tagged_union.hpp +++ b/tests/test_tagged_union.hpp @@ -32,6 +32,5 @@ void test_tagged_union() { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r, - "{\"shape\":\"Rectangle\",\"height\":10.0,\"width\":5.0}"); + write_and_read(r, R"({"shape":"Rectangle","height":10.0,"width":5.0})"); } diff --git a/tests/test_timestamp.hpp b/tests/test_timestamp.hpp index b5398f12..67b0866b 100644 --- a/tests/test_timestamp.hpp +++ b/tests/test_timestamp.hpp @@ -27,7 +27,7 @@ void test_timestamp() { const auto bart = Person{.first_name = "Bart", .birthday = "1987-04-19"}; - write_and_read(bart, - "{\"firstName\":\"Bart\",\"lastName\":\"Simpson\"," - "\"birthday\":\"1987-04-19\"}"); + write_and_read( + bart, + R"({"firstName":"Bart","lastName":"Simpson","birthday":"1987-04-19"})"); } diff --git a/tests/test_unique_ptr.hpp b/tests/test_unique_ptr.hpp index 8ac31875..54a38543 100644 --- a/tests/test_unique_ptr.hpp +++ b/tests/test_unique_ptr.hpp @@ -27,8 +27,5 @@ void test_unique_ptr() { write_and_read( homer, - "{\"firstName\":\"Homer\",\"lastName\":\"Simpson\",\"children\":[{" - "\"firstName\":\"Bart\",\"lastName\":\"Simpson\"},{" - "\"firstName\":\"Lisa\",\"lastName\":\"Simpson\"},{" - "\"firstName\":\"Maggie\",\"lastName\":\"Simpson\"}]}"); + R"({"firstName":"Homer","lastName":"Simpson","children":[{"firstName":"Bart","lastName":"Simpson"},{"firstName":"Lisa","lastName":"Simpson"},{"firstName":"Maggie","lastName":"Simpson"}]})"); } diff --git a/tests/test_unique_ptr2.hpp b/tests/test_unique_ptr2.hpp index d5083cc0..aae61b15 100644 --- a/tests/test_unique_ptr2.hpp +++ b/tests/test_unique_ptr2.hpp @@ -41,7 +41,5 @@ void test_unique_ptr2() { write_and_read( tree, - "{\"leafOrNode\":{\"type\":\"Node\",\"criticalValue\":10.0,\"left\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":3.0}},\"right\":{" - "\"leafOrNode\":{\"type\":\"Leaf\",\"value\":5.0}}}}"); + R"({"leafOrNode":{"type":"Node","criticalValue":10.0,"left":{"leafOrNode":{"type":"Leaf","value":3.0}},"right":{"leafOrNode":{"type":"Leaf","value":5.0}}}})"); } diff --git a/tests/test_variant.hpp b/tests/test_variant.hpp index 5012a1dc..0eeab501 100644 --- a/tests/test_variant.hpp +++ b/tests/test_variant.hpp @@ -28,5 +28,5 @@ void test_variant() { const Shapes r = Rectangle{.height = 10, .width = 5}; - write_and_read(r, "{\"height\":10.0,\"width\":5.0}"); + write_and_read(r, R"({"height":10.0,"width":5.0})"); }