Skip to content

Commit

Permalink
Add regression test for nlohmann#3134
Browse files Browse the repository at this point in the history
  • Loading branch information
falbrechtskirchinger committed Jul 29, 2022
1 parent d9dae0c commit b9096d9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/src/unit-regression2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,21 @@ TEST_CASE("regression tests 2")
CHECK(a2.type() == typeid(j));
}
#endif

SECTION("issue #3134 - Applying JSON patch creates parent object")
{
json doc = R"({
"a": {}
})"_json;
json patch = R"([{
"op": "add",
"path": "/a/b/c",
"value": 1
}])"_json;

// patch should cause an error because "b" does not exist in doc
CHECK_THROWS_WITH_AS(doc.patch(patch), "[json.exception.out_of_range.403] key 'b' not found", json::out_of_range&);
}
}

DOCTEST_CLANG_SUPPRESS_WARNING_POP

0 comments on commit b9096d9

Please sign in to comment.