Skip to content

Commit

Permalink
Added failing example code from nlohmann#3007 as extra test.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyVH committed Sep 12, 2021
1 parent 0989a3c commit 8a14bad
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/src/unit-diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ TEST_CASE("Better diagnostics")

SECTION("Regression test for issue #3007 - Parent pointers properly set when using update()")
{
// void update(const_reference j)
{
// void update(const_reference j)
json j = json::object();

{
Expand All @@ -203,8 +203,8 @@ TEST_CASE("Better diagnostics")
CHECK_THROWS_WITH_AS(constJ["one"].at(0), "[json.exception.type_error.304] (/one) cannot use at() with number", json::type_error);
}

// void update(const_iterator first, const_iterator last)
{
// void update(const_iterator first, const_iterator last)
json j = json::object();

{
Expand All @@ -218,5 +218,20 @@ TEST_CASE("Better diagnostics")
auto const& constJ = j;
CHECK_THROWS_WITH_AS(constJ["one"].at(0), "[json.exception.type_error.304] (/one) cannot use at() with number", json::type_error);
}

// Code from #3007 triggering unwanted assertion without fix to update().
{
json root = json::array();
json lower = json::object();

{
json lowest = json::object();
lowest["one"] = 1;

lower.update(lowest);
}

root.push_back(lower);
}
}
}

0 comments on commit 8a14bad

Please sign in to comment.