some cleanup for #83

This commit is contained in:
Niels 2015-12-22 18:07:51 +01:00
parent 67c2d90a21
commit 00f9296db5
3 changed files with 26 additions and 4 deletions

View file

@ -6163,7 +6163,7 @@ class basic_json
{ {
private: private:
/// the container to iterate /// the container to iterate
basic_json& container; typename basic_json::reference container;
/// the type of the iterator to use while iteration /// the type of the iterator to use while iteration
using json_iterator = decltype(std::begin(container)); using json_iterator = decltype(std::begin(container));
@ -6236,7 +6236,7 @@ class basic_json
public: public:
/// construct iterator wrapper from a container /// construct iterator wrapper from a container
iterator_wrapper(basic_json& cont) iterator_wrapper(typename basic_json::reference cont)
: container(cont) : container(cont)
{} {}

View file

@ -6163,7 +6163,7 @@ class basic_json
{ {
private: private:
/// the container to iterate /// the container to iterate
basic_json& container; typename basic_json::reference container;
/// the type of the iterator to use while iteration /// the type of the iterator to use while iteration
using json_iterator = decltype(std::begin(container)); using json_iterator = decltype(std::begin(container));
@ -6236,7 +6236,7 @@ class basic_json
public: public:
/// construct iterator wrapper from a container /// construct iterator wrapper from a container
iterator_wrapper(basic_json& cont) iterator_wrapper(typename basic_json::reference cont)
: container(cont) : container(cont)
{} {}

View file

@ -9555,6 +9555,10 @@ TEST_CASE("iterator_wrapper")
{ {
CHECK(i.key() == "A"); CHECK(i.key() == "A");
CHECK(i.value() == json(1)); CHECK(i.value() == json(1));
// change the value
i.value() = json(11);
CHECK(i.value() == json(11));
break; break;
} }
@ -9562,6 +9566,10 @@ TEST_CASE("iterator_wrapper")
{ {
CHECK(i.key() == "B"); CHECK(i.key() == "B");
CHECK(i.value() == json(2)); CHECK(i.value() == json(2));
// change the value
i.value() = json(22);
CHECK(i.value() == json(22));
break; break;
} }
@ -9573,6 +9581,9 @@ TEST_CASE("iterator_wrapper")
} }
CHECK(counter == 3); CHECK(counter == 3);
// check if values where changed
CHECK(j == json({{"A", 11}, {"B", 22}}));
} }
SECTION("const value") SECTION("const value")
@ -9690,6 +9701,10 @@ TEST_CASE("iterator_wrapper")
{ {
CHECK(i.key() == "0"); CHECK(i.key() == "0");
CHECK(i.value() == "A"); CHECK(i.value() == "A");
// change the value
i.value() = "AA";
CHECK(i.value() == "AA");
break; break;
} }
@ -9697,6 +9712,10 @@ TEST_CASE("iterator_wrapper")
{ {
CHECK(i.key() == "1"); CHECK(i.key() == "1");
CHECK(i.value() == "B"); CHECK(i.value() == "B");
// change the value
i.value() = "BB";
CHECK(i.value() == "BB");
break; break;
} }
@ -9708,6 +9727,9 @@ TEST_CASE("iterator_wrapper")
} }
CHECK(counter == 3); CHECK(counter == 3);
// check if values where changed
CHECK(j == json({"AA", "BB"}));
} }
SECTION("const value") SECTION("const value")