Use R-strings for the tests

This commit is contained in:
Patrick Urbanke
2023-10-07 12:42:06 +02:00
parent f926143c14
commit 499011c8ba
14 changed files with 17 additions and 40 deletions
+1 -3
View File
@@ -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}}}})");
}
+1 -2
View File
@@ -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":[]})");
}
+2 -2
View File
@@ -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})");
}
+1 -4
View File
@@ -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":[]}]})");
}
+1 -1
View File
@@ -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}})");
}
+1 -2
View File
@@ -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":[]})");
}
+1 -4
View File
@@ -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"}]})");
}
+1 -6
View File
@@ -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":[]}]})");
}
+1 -3
View File
@@ -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}}}})");
}
+1 -2
View File
@@ -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})");
}
+3 -3
View File
@@ -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"})");
}
+1 -4
View File
@@ -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"}]})");
}
+1 -3
View File
@@ -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}}}})");
}
+1 -1
View File
@@ -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})");
}