From f585fe4eece44413982900f3b1b724cb7eabe541 Mon Sep 17 00:00:00 2001 From: Perry Kundert Date: Mon, 2 Oct 2017 14:17:23 -0700 Subject: [PATCH] Test to confirm parsing of multiple JSON records in a istream #367 --- test/src/unit-regression.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index 0c0d148da..2d30a52c5 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -1233,4 +1233,24 @@ TEST_CASE("regression tests") "[json.exception.type_error.302] type must be array, but is null"); } } + + SECTION("issue #367 - Behavior of operator>> should more closely resemble that of built-in overloads.") + { + SECTION("example 1") + { + std::istringstream i1_2_3( "{\"first\": \"one\" }{\"second\": \"two\"}3" ); + json j1, j2, j3; + i1_2_3 >> j1; + i1_2_3 >> j2; + i1_2_3 >> j3; + + std::map m1 = j1; + std::map m2 = j2; + int i3 = j3; + + CHECK( m1 == ( std::map {{ "first", "one" }} )); + CHECK( m2 == ( std::map {{ "second", "two" }} )); + CHECK( i3 == 3 ); + } + } }