Commit d14366c3 authored by Niels's avatar Niels

Merge branch 'feature/issue269' into develop

parents 6f76c923 7cff6c87
......@@ -502,7 +502,11 @@ $ make
$ ./json_unit "*"
===============================================================================
<<<<<<< HEAD
All tests passed (5568722 assertions in 32 test cases)
=======
All tests passed (5568721 assertions in 32 test cases)
>>>>>>> develop
```
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
......@@ -10002,9 +10002,12 @@ basic_json_parser_63:
// in a second pass, traverse the remaining elements
// remove my remaining elements
const auto end_index = static_cast<difference_type>(result.size());
while (i < source.size())
{
result.push_back(object(
// add operations in reverse order to avoid invalid
// indices
result.insert(result.begin() + end_index, object(
{
{"op", "remove"},
{"path", path + "/" + std::to_string(i)}
......
......@@ -9312,9 +9312,12 @@ class basic_json
// in a second pass, traverse the remaining elements
// remove my remaining elements
const auto end_index = static_cast<difference_type>(result.size());
while (i < source.size())
{
result.push_back(object(
// add operations in reverse order to avoid invalid
// indices
result.insert(result.begin() + end_index, object(
{
{"op", "remove"},
{"path", path + "/" + std::to_string(i)}
......
......@@ -14107,6 +14107,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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment