Add error message for json read (#461)

This commit is contained in:
Lixin Wei
2025-07-16 09:23:34 +02:00
committed by GitHub
parent 18feb02099
commit 238a1975da
2 changed files with 13 additions and 6 deletions
+4 -4
View File
@@ -37,13 +37,13 @@ TEST(json, test_decode_error_without_exception) {
R"({"firstName":"Homer";"lastName":"Simpson";"birthday":"1987-04-19"})";
rfl::Result<Person> result = rfl::error("result didn't get set");
EXPECT_NO_THROW({
result = rfl::json::read<Person>(faulty_string);
});
EXPECT_NO_THROW({ result = rfl::json::read<Person>(faulty_string); });
EXPECT_TRUE(!result.has_value() && true);
EXPECT_EQ(result.error().what(), "Could not parse document");
EXPECT_EQ(result.error().what(),
"Could not parse document: unexpected character, expected a comma "
"or a closing brace");
}
} // namespace test_error_messages