Skip to content

Commit

Permalink
some cleanup for #83
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Dec 22, 2015
1 parent 67c2d90 commit 00f9296
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6163,7 +6163,7 @@ class basic_json
{
private:
/// the container to iterate
basic_json& container;
typename basic_json::reference container;
/// the type of the iterator to use while iteration
using json_iterator = decltype(std::begin(container));

Expand Down Expand Up @@ -6236,7 +6236,7 @@ class basic_json

public:
/// construct iterator wrapper from a container
iterator_wrapper(basic_json& cont)
iterator_wrapper(typename basic_json::reference cont)
: container(cont)
{}

Expand Down
4 changes: 2 additions & 2 deletions src/json.hpp.re2c
Original file line number Diff line number Diff line change
Expand Up @@ -6163,7 +6163,7 @@ class basic_json
{
private:
/// the container to iterate
basic_json& container;
typename basic_json::reference container;
/// the type of the iterator to use while iteration
using json_iterator = decltype(std::begin(container));

Expand Down Expand Up @@ -6236,7 +6236,7 @@ class basic_json

public:
/// construct iterator wrapper from a container
iterator_wrapper(basic_json& cont)
iterator_wrapper(typename basic_json::reference cont)
: container(cont)
{}

Expand Down
22 changes: 22 additions & 0 deletions test/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9555,13 +9555,21 @@ TEST_CASE("iterator_wrapper")
{
CHECK(i.key() == "A");
CHECK(i.value() == json(1));

// change the value
i.value() = json(11);
CHECK(i.value() == json(11));
break;
}

case 2:
{
CHECK(i.key() == "B");
CHECK(i.value() == json(2));

// change the value
i.value() = json(22);
CHECK(i.value() == json(22));
break;
}

Expand All @@ -9573,6 +9581,9 @@ TEST_CASE("iterator_wrapper")
}

CHECK(counter == 3);

// check if values where changed
CHECK(j == json({{"A", 11}, {"B", 22}}));
}

SECTION("const value")
Expand Down Expand Up @@ -9690,13 +9701,21 @@ TEST_CASE("iterator_wrapper")
{
CHECK(i.key() == "0");
CHECK(i.value() == "A");

// change the value
i.value() = "AA";
CHECK(i.value() == "AA");
break;
}

case 2:
{
CHECK(i.key() == "1");
CHECK(i.value() == "B");

// change the value
i.value() = "BB";
CHECK(i.value() == "BB");
break;
}

Expand All @@ -9708,6 +9727,9 @@ TEST_CASE("iterator_wrapper")
}

CHECK(counter == 3);

// check if values where changed
CHECK(j == json({"AA", "BB"}));
}

SECTION("const value")
Expand Down

0 comments on commit 00f9296

Please sign in to comment.