From 6e6dd5f45dbae03ca02aef30792fc475f668ba31 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 24 Jun 2015 15:46:50 +0200 Subject: [PATCH] added test cases for the last uncovered lines --- test/unit.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/unit.cpp b/test/unit.cpp index b0d20ef4..a960b2be 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -8009,6 +8009,39 @@ TEST_CASE("parser class") } } } + + SECTION("special cases") + { + // the following test cases cover the situation in which an empty + // object and array is discarded only after the closing character + // has been read + + json j_empty_object = json::parse("{}", [](int, json::parse_event_t e, const json&) + { + if (e == json::parse_event_t::object_end) + { + return false; + } + else + { + return true; + } + }); + CHECK(j_empty_object == json()); + + json j_empty_array = json::parse("[]", [](int, json::parse_event_t e, const json&) + { + if (e == json::parse_event_t::array_end) + { + return false; + } + else + { + return true; + } + }); + CHECK(j_empty_array == json()); + } } }