From f03c6ce45845c9ba3e39fe49ca6b4370d1c93e87 Mon Sep 17 00:00:00 2001
From: Niels <niels.lohmann@gmail.com>
Date: Sun, 12 Apr 2015 16:57:51 +0200
Subject: [PATCH] added missing test cases

---
 src/json.hpp      |  2 +-
 src/json.hpp.re2c |  2 +-
 test/unit.cpp     | 22 +++++++++++++++-------
 3 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/json.hpp b/src/json.hpp
index 877c54cf..12026cb0 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -3541,7 +3541,7 @@ class basic_json
         }
 
         /// return the value of an iterator
-        inline reference value() const
+        inline const_reference value() const
         {
             return this->base().operator * ();
         }
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index 2aa5c7fb..738295a0 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -3541,7 +3541,7 @@ class basic_json
         }
 
         /// return the value of an iterator
-        inline reference value() const
+        inline const_reference value() const
         {
             return this->base().operator * ();
         }
diff --git a/test/unit.cpp b/test/unit.cpp
index c4e669a7..58f5af7c 100644
--- a/test/unit.cpp
+++ b/test/unit.cpp
@@ -3846,7 +3846,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json(true));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK(rit.value() == json(true));
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -4044,7 +4044,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json("hello world"));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK(rit.value() == json("hello world"));
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -4235,7 +4235,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json(1));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK(rit.value() == json(1));
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -4426,7 +4426,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json(1));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK(rit.key() == "A");
                 CHECK(rit.value() == json(1));
                 CHECK(crit.key() == "A");
@@ -4624,7 +4624,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json(23));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK(rit.value() == json(23));
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -4822,7 +4822,7 @@ TEST_CASE("iterators")
                 CHECK(cit.value() == json(23.42));
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK(rit.value() == json(23.42));
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -4890,7 +4890,7 @@ TEST_CASE("iterators")
                 CHECK_THROWS_AS(cit.value(), std::out_of_range);
 
                 auto rit = j.rend();
-                auto crit = j.rend();
+                auto crit = j.crend();
                 CHECK_THROWS_AS(rit.key(), std::domain_error);
                 CHECK_THROWS_AS(rit.value(), std::out_of_range);
                 CHECK_THROWS_AS(crit.key(), std::domain_error);
@@ -6328,6 +6328,14 @@ TEST_CASE("serialization")
 
 TEST_CASE("deserialization")
 {
+    SECTION("stream")
+    {
+        std::stringstream ss;
+        ss << "[\"foo\",1,2,3,false,{\"one\":1}]";
+        json j = json::parse(ss);
+        CHECK(j == json({"foo", 1, 2, 3, false, {{"one", 1}}}));
+    }
+
     SECTION("string")
     {
         auto s = "[\"foo\",1,2,3,false,{\"one\":1}]";