mirror of
https://github.com/nlohmann/json.git
synced 2026-10-08 15:37:13 +00:00
Add tests for error_handler_t::keep in dump() (#4555)
Squashed onto develop from: - Add error_handler_t::keep to copy invalid UTF-8 bytes unchanged - Mention error_handler_t::keep in the README Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
e752688b52
commit
3c465beb61
7 files changed
+76
-4
No files matched your search
@@ -888,6 +888,15 @@ TEST_CASE("regression tests 2")
|
||||
CHECK(j == k);
|
||||
}
|
||||
|
||||
SECTION("issue #4552 - UTF-8 invalid characters are not always ignored when dumping with error_handler_t::ignore")
|
||||
{
|
||||
json node;
|
||||
node["test"] = "test\334\005";
|
||||
CHECK(node.dump(-1, ' ', false, json::error_handler_t::ignore) == "{\"test\":\"test\\u0005\"}");
|
||||
CHECK(node.dump(-1, ' ', false, json::error_handler_t::keep) == "{\"test\":\"test\334\\u0005\"}");
|
||||
CHECK(node.dump(-1, ' ', true, json::error_handler_t::keep) == "{\"test\":\"test\334\\u0005\"}");
|
||||
}
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
SECTION("issue #5066 - MSVC converts json to std::variant<json> via the conversion operator")
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user