diff --git a/README.md b/README.md index 9f78413f..7efcabc5 100644 --- a/README.md +++ b/README.md @@ -453,7 +453,7 @@ $ make $ ./json_unit "*" =============================================================================== -All tests passed (5568705 assertions in 31 test cases) +All tests passed (5568722 assertions in 32 test cases) ``` For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). diff --git a/test/src/unit.cpp b/test/src/unit.cpp index 609e1be9..12611b3f 100644 --- a/test/src/unit.cpp +++ b/test/src/unit.cpp @@ -14073,6 +14073,15 @@ TEST_CASE("regression tests") CHECK(data == json({{"key", "value"}, {"key2", "value2"}, {"key3", "value3"}})); } + + SECTION("issue #269 - diff generates incorrect patch when removing multiple array elements") + { + json doc = R"( { "arr1": [1, 2, 3, 4] } )"_json; + json expected = R"( { "arr1": [1, 2] } )"_json; + + // check roundtrip + CHECK(doc.patch(json::diff(doc, expected)) == expected); + } } // special test case to check if memory is leaked if constructor throws