Removing trailing whitespace.

This commit is contained in:
Francisco Geiman Thiesen
2025-07-18 10:49:47 +00:00
parent a27a17484d
commit d874ab7239
3 changed files with 95 additions and 95 deletions
+27 -27
View File
@@ -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<StatusStruct>();
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<StatusStruct>();
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<StatusStruct>();
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<Task>();
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<Response>();
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<Date>();
ASSERT_SUCCESS(get_result);
Date deserialized = std::move(get_result.value());
ASSERT_TRUE(deserialized.day == Day::Friday);
ASSERT_TRUE(deserialized.month == Month::July);