mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
Use R-strings for the tests
This commit is contained in:
+1
-3
@@ -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}}}})");
|
||||
}
|
||||
|
||||
@@ -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":[]})");
|
||||
}
|
||||
|
||||
@@ -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})");
|
||||
}
|
||||
|
||||
@@ -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":[]}]})");
|
||||
}
|
||||
|
||||
@@ -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}})");
|
||||
}
|
||||
|
||||
@@ -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":[]})");
|
||||
}
|
||||
|
||||
@@ -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"}]})");
|
||||
}
|
||||
|
||||
@@ -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
@@ -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}}}})");
|
||||
}
|
||||
|
||||
@@ -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})");
|
||||
}
|
||||
|
||||
@@ -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"})");
|
||||
}
|
||||
|
||||
@@ -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"}]})");
|
||||
}
|
||||
|
||||
@@ -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}}}})");
|
||||
}
|
||||
|
||||
@@ -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})");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user