Merge branch 'feature/issue269' into develop
This commit is contained in:
commit
d14366c33e
4 changed files with 21 additions and 2 deletions
|
@ -502,7 +502,11 @@ $ make
|
||||||
$ ./json_unit "*"
|
$ ./json_unit "*"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
<<<<<<< HEAD
|
||||||
|
All tests passed (5568722 assertions in 32 test cases)
|
||||||
|
=======
|
||||||
All tests passed (5568721 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).
|
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
|
// in a second pass, traverse the remaining elements
|
||||||
|
|
||||||
// remove my remaining elements
|
// remove my remaining elements
|
||||||
|
const auto end_index = static_cast<difference_type>(result.size());
|
||||||
while (i < source.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"},
|
{"op", "remove"},
|
||||||
{"path", path + "/" + std::to_string(i)}
|
{"path", path + "/" + std::to_string(i)}
|
||||||
|
|
|
@ -9312,9 +9312,12 @@ class basic_json
|
||||||
// in a second pass, traverse the remaining elements
|
// in a second pass, traverse the remaining elements
|
||||||
|
|
||||||
// remove my remaining elements
|
// remove my remaining elements
|
||||||
|
const auto end_index = static_cast<difference_type>(result.size());
|
||||||
while (i < source.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"},
|
{"op", "remove"},
|
||||||
{"path", path + "/" + std::to_string(i)}
|
{"path", path + "/" + std::to_string(i)}
|
||||||
|
|
|
@ -14107,6 +14107,15 @@ TEST_CASE("regression tests")
|
||||||
|
|
||||||
CHECK(data == json({{"key", "value"}, {"key2", "value2"}, {"key3", "value3"}}));
|
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
|
// special test case to check if memory is leaked if constructor throws
|
||||||
|
|
Loading…
Reference in a new issue