From d874ab723953b1c65e1a2fb126f90d7344e6845c Mon Sep 17 00:00:00 2001 From: Francisco Geiman Thiesen Date: Fri, 18 Jul 2025 10:49:47 +0000 Subject: [PATCH] Removing trailing whitespace. --- .../static_reflection_comprehensive_tests.cpp | 72 +++++++++---------- .../static_reflection_edge_cases_tests.cpp | 64 ++++++++--------- .../builder/static_reflection_enum_tests.cpp | 54 +++++++------- 3 files changed, 95 insertions(+), 95 deletions(-) diff --git a/tests/builder/static_reflection_comprehensive_tests.cpp b/tests/builder/static_reflection_comprehensive_tests.cpp index 2227f503e..ef8eb1e2b 100644 --- a/tests/builder/static_reflection_comprehensive_tests.cpp +++ b/tests/builder/static_reflection_comprehensive_tests.cpp @@ -22,26 +22,26 @@ namespace builder_tests { double double_val; float float_val; }; - + PrimitiveTypes test{true, 'X', 42, 3.14159, 2.71f}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"bool_val\":true") != std::string::npos); ASSERT_TRUE(json.find("\"char_val\":\"X\"") != std::string::npos); ASSERT_TRUE(json.find("\"int_val\":42") != std::string::npos); ASSERT_TRUE(json.find("\"double_val\":3.14159") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + PrimitiveTypes deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.bool_val, test.bool_val); ASSERT_EQUAL(deserialized.char_val, test.char_val); @@ -58,24 +58,24 @@ namespace builder_tests { std::string string_val; std::string_view string_view_val; }; - + StringTypes test{"hello world", "test_view"}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"string_val\":\"hello world\"") != std::string::npos); ASSERT_TRUE(json.find("\"string_view_val\":\"test_view\"") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + StringTypes deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.string_val, test.string_val); #endif @@ -91,30 +91,30 @@ namespace builder_tests { std::optional opt_int_null; std::optional opt_string_null; }; - + OptionalTypes test; test.opt_int_with_value = 42; test.opt_string_with_value = "optional_test"; test.opt_int_null = std::nullopt; test.opt_string_null = std::nullopt; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"opt_int_with_value\":42") != std::string::npos); ASSERT_TRUE(json.find("\"opt_string_with_value\":\"optional_test\"") != std::string::npos); ASSERT_TRUE(json.find("\"opt_int_null\":null") != std::string::npos); ASSERT_TRUE(json.find("\"opt_string_null\":null") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + OptionalTypes deserialized = std::move(get_result.value()); ASSERT_TRUE(deserialized.opt_int_with_value.has_value()); ASSERT_EQUAL(*deserialized.opt_int_with_value, 42); @@ -136,32 +136,32 @@ namespace builder_tests { std::unique_ptr unique_int_null; std::shared_ptr shared_string_null; }; - + SmartPointerTypes test; test.unique_int_with_value = std::make_unique(123); test.shared_string_with_value = std::make_shared("shared_test"); test.unique_bool_with_value = std::make_unique(true); test.unique_int_null = nullptr; test.shared_string_null = nullptr; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"unique_int_with_value\":123") != std::string::npos); ASSERT_TRUE(json.find("\"shared_string_with_value\":\"shared_test\"") != std::string::npos); ASSERT_TRUE(json.find("\"unique_bool_with_value\":true") != std::string::npos); ASSERT_TRUE(json.find("\"unique_int_null\":null") != std::string::npos); ASSERT_TRUE(json.find("\"shared_string_null\":null") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + SmartPointerTypes deserialized = std::move(get_result.value()); ASSERT_TRUE(deserialized.unique_int_with_value != nullptr); ASSERT_EQUAL(*deserialized.unique_int_with_value, 123); @@ -183,28 +183,28 @@ namespace builder_tests { std::set string_set; std::map string_map; }; - + ContainerTypes test; test.int_vector = {1, 2, 3, 4, 5}; test.string_set = {"apple", "banana", "cherry"}; test.string_map = {{"key1", 10}, {"key2", 20}, {"key3", 30}}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"int_vector\":[1,2,3,4,5]") != std::string::npos); ASSERT_TRUE(json.find("\"string_set\":[") != std::string::npos); ASSERT_TRUE(json.find("\"string_map\":{") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + ContainerTypes deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.int_vector.size(), 5); ASSERT_EQUAL(deserialized.string_set.size(), 3); @@ -217,30 +217,30 @@ namespace builder_tests { bool test_individual_serialization() { TEST_START(); - + // Test individual type serialization (not part of structs) auto bool_result = builder::to_json_string(true); ASSERT_SUCCESS(bool_result); ASSERT_EQUAL(bool_result.value(), "true"); - + auto int_result = builder::to_json_string(42); ASSERT_SUCCESS(int_result); ASSERT_EQUAL(int_result.value(), "42"); - + auto string_result = builder::to_json_string(std::string("hello")); ASSERT_SUCCESS(string_result); ASSERT_EQUAL(string_result.value(), "\"hello\""); - + auto char_result = builder::to_json_string('X'); ASSERT_SUCCESS(char_result); ASSERT_EQUAL(char_result.value(), "\"X\""); - + // Test const char* serialization (serialization only, not round-trip) const char* cstring = "cstring"; auto cstring_result = builder::to_json_string(cstring); ASSERT_SUCCESS(cstring_result); ASSERT_EQUAL(cstring_result.value(), "\"cstring\""); - + TEST_SUCCEED(); } diff --git a/tests/builder/static_reflection_edge_cases_tests.cpp b/tests/builder/static_reflection_edge_cases_tests.cpp index 1c4e78566..27047fbba 100644 --- a/tests/builder/static_reflection_edge_cases_tests.cpp +++ b/tests/builder/static_reflection_edge_cases_tests.cpp @@ -20,32 +20,32 @@ namespace builder_tests { std::unique_ptr null_unique_ptr; std::shared_ptr null_shared_ptr; }; - + EmptyValues test; test.empty_string = ""; // empty_vector is already empty by default test.null_optional = std::nullopt; test.null_unique_ptr = nullptr; test.null_shared_ptr = nullptr; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"empty_string\":\"\"") != std::string::npos); ASSERT_TRUE(json.find("\"empty_vector\":[]") != std::string::npos); ASSERT_TRUE(json.find("\"null_optional\":null") != std::string::npos); ASSERT_TRUE(json.find("\"null_unique_ptr\":null") != std::string::npos); ASSERT_TRUE(json.find("\"null_shared_ptr\":null") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + EmptyValues deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.empty_string, ""); ASSERT_EQUAL(deserialized.empty_vector.size(), 0); @@ -66,26 +66,26 @@ namespace builder_tests { std::string unicode; char null_char; }; - + SpecialChars test; test.quotes = "He said \"Hello\""; test.backslashes = "Path\\to\\file"; test.newlines = "Line1\nLine2\tTabbed"; test.unicode = "Café résumé"; test.null_char = '\0'; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); // Test that quotes are properly escaped ASSERT_TRUE(json.find("\\\"Hello\\\"") != std::string::npos); - // Test that backslashes are properly escaped + // Test that backslashes are properly escaped ASSERT_TRUE(json.find("\\\\to\\\\") != std::string::npos); // Test that newlines are properly escaped ASSERT_TRUE(json.find("\\n") != std::string::npos); ASSERT_TRUE(json.find("\\t") != std::string::npos); - + // Test round-trip (excluding null char which has special handling) struct SpecialCharsNoNull { std::string quotes; @@ -93,23 +93,23 @@ namespace builder_tests { std::string newlines; std::string unicode; }; - + SpecialCharsNoNull test_no_null; test_no_null.quotes = test.quotes; test_no_null.backslashes = test.backslashes; test_no_null.newlines = test.newlines; test_no_null.unicode = test.unicode; - + auto result_no_null = builder::to_json_string(test_no_null); ASSERT_SUCCESS(result_no_null); - + ondemand::parser parser; auto doc_result = parser.iterate(pad(result_no_null.value())); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + SpecialCharsNoNull deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.quotes, test.quotes); ASSERT_EQUAL(deserialized.backslashes, test.backslashes); @@ -130,7 +130,7 @@ namespace builder_tests { bool true_val; bool false_val; }; - + NumericLimits test; test.max_int = std::numeric_limits::max(); test.min_int = std::numeric_limits::min(); @@ -138,22 +138,22 @@ namespace builder_tests { test.min_double = -1e100; // Large negative but safe double value test.true_val = true; test.false_val = false; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"true_val\":true") != std::string::npos); ASSERT_TRUE(json.find("\"false_val\":false") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + NumericLimits deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.max_int, test.max_int); ASSERT_EQUAL(deserialized.min_int, test.min_int); @@ -170,37 +170,37 @@ namespace builder_tests { int value; std::string name; }; - + struct Outer { Inner inner_obj; std::vector inner_vector; std::optional optional_inner; std::unique_ptr unique_inner; }; - + Outer test; test.inner_obj = {42, "inner"}; test.inner_vector = {{1, "first"}, {2, "second"}}; test.optional_inner = Inner{99, "optional"}; test.unique_inner = std::make_unique(Inner{123, "unique"}); - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"inner_obj\":{") != std::string::npos); ASSERT_TRUE(json.find("\"inner_vector\":[") != std::string::npos); ASSERT_TRUE(json.find("\"optional_inner\":{") != std::string::npos); ASSERT_TRUE(json.find("\"unique_inner\":{") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + Outer deserialized = std::move(get_result.value()); ASSERT_EQUAL(deserialized.inner_obj.value, 42); ASSERT_EQUAL(deserialized.inner_obj.name, "inner"); @@ -217,20 +217,20 @@ namespace builder_tests { bool test_const_char_serialization_only() { TEST_START(); - + // Test that const char* can be serialized (but not round-tripped) const char* test_cstring = "const char test"; auto result = builder::to_json_string(test_cstring); ASSERT_SUCCESS(result); ASSERT_EQUAL(result.value(), "\"const char test\""); - + // Test with special characters in const char* const char* special_cstring = "quotes\"and\\backslashes"; auto special_result = builder::to_json_string(special_cstring); ASSERT_SUCCESS(special_result); ASSERT_TRUE(special_result.value().find("\\\"") != std::string::npos); ASSERT_TRUE(special_result.value().find("\\\\") != std::string::npos); - + TEST_SUCCEED(); } diff --git a/tests/builder/static_reflection_enum_tests.cpp b/tests/builder/static_reflection_enum_tests.cpp index 095dcc99a..22ceb37c7 100644 --- a/tests/builder/static_reflection_enum_tests.cpp +++ b/tests/builder/static_reflection_enum_tests.cpp @@ -21,22 +21,22 @@ namespace builder_tests { }; EnumStruct test{Color::Red, 42}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); // Enum should be serialized as string (Red) ASSERT_TRUE(json.find("\"color\":\"Red\"") != std::string::npos); ASSERT_TRUE(json.find("\"value\":42") != std::string::npos); - + // Test different enum values test.color = Color::Green; auto result2 = builder::to_json_string(test); ASSERT_SUCCESS(result2); std::string json2 = result2.value(); ASSERT_TRUE(json2.find("\"color\":\"Green\"") != std::string::npos); - + test.color = Color::Blue; auto result3 = builder::to_json_string(test); ASSERT_SUCCESS(result3); @@ -65,36 +65,36 @@ namespace builder_tests { ondemand::parser parser1; auto doc_result1 = parser1.iterate(pad(json1)); ASSERT_SUCCESS(doc_result1); - + auto get_result1 = doc_result1.value().get(); ASSERT_SUCCESS(get_result1); - + StatusStruct deserialized1 = std::move(get_result1.value()); ASSERT_TRUE(deserialized1.status == Status::Active); ASSERT_EQUAL(deserialized1.name, "test1"); - + // Test Status::Inactive std::string json2 = "{\"status\":\"Inactive\",\"name\":\"test2\"}"; ondemand::parser parser2; auto doc_result2 = parser2.iterate(pad(json2)); ASSERT_SUCCESS(doc_result2); - + auto get_result2 = doc_result2.value().get(); ASSERT_SUCCESS(get_result2); - + StatusStruct deserialized2 = std::move(get_result2.value()); ASSERT_TRUE(deserialized2.status == Status::Inactive); ASSERT_EQUAL(deserialized2.name, "test2"); - + // Test Status::Pending std::string json3 = "{\"status\":\"Pending\",\"name\":\"test3\"}"; ondemand::parser parser3; auto doc_result3 = parser3.iterate(pad(json3)); ASSERT_SUCCESS(doc_result3); - + auto get_result3 = doc_result3.value().get(); ASSERT_SUCCESS(get_result3); - + StatusStruct deserialized3 = std::move(get_result3.value()); ASSERT_TRUE(deserialized3.status == Status::Pending); ASSERT_EQUAL(deserialized3.name, "test3"); @@ -119,24 +119,24 @@ namespace builder_tests { }; Task original{Priority::High, "Important task", 123}; - + // Serialize auto serialize_result = builder::to_json_string(original); ASSERT_SUCCESS(serialize_result); - + std::string json = serialize_result.value(); ASSERT_TRUE(json.find("\"priority\":\"High\"") != std::string::npos); // High as string ASSERT_TRUE(json.find("\"description\":\"Important task\"") != std::string::npos); ASSERT_TRUE(json.find("\"id\":123") != std::string::npos); - + // Deserialize ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + Task deserialized = std::move(get_result.value()); ASSERT_TRUE(deserialized.priority == Priority::High); ASSERT_EQUAL(deserialized.description, "Important task"); @@ -160,22 +160,22 @@ namespace builder_tests { }; Response test{ErrorCode::NotFound, "Resource not found"}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"error\":\"NotFound\"") != std::string::npos); ASSERT_TRUE(json.find("\"message\":\"Resource not found\"") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + Response deserialized = std::move(get_result.value()); ASSERT_TRUE(deserialized.error == ErrorCode::NotFound); ASSERT_EQUAL(deserialized.message, "Resource not found"); @@ -218,23 +218,23 @@ namespace builder_tests { }; Date test{Day::Friday, Month::July, 2024}; - + auto result = builder::to_json_string(test); ASSERT_SUCCESS(result); - + std::string json = result.value(); ASSERT_TRUE(json.find("\"day\":\"Friday\"") != std::string::npos); // Friday as string ASSERT_TRUE(json.find("\"month\":\"July\"") != std::string::npos); // July as string ASSERT_TRUE(json.find("\"year\":2024") != std::string::npos); - + // Test round-trip ondemand::parser parser; auto doc_result = parser.iterate(pad(json)); ASSERT_SUCCESS(doc_result); - + auto get_result = doc_result.value().get(); ASSERT_SUCCESS(get_result); - + Date deserialized = std::move(get_result.value()); ASSERT_TRUE(deserialized.day == Day::Friday); ASSERT_TRUE(deserialized.month == Month::July);