Merge branch 'feature/issue269' into develop

This commit is contained in:
Niels 2016-06-23 00:05:01 +02:00
commit d14366c33e
4 changed files with 21 additions and 2 deletions

View file

@ -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).

View file

@ -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)}

View file

@ -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)}

View file

@ -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