From a3210ee2a9917a39a8d6d3bb36f90ec52af37bc7 Mon Sep 17 00:00:00 2001 From: Niels Date: Sat, 11 Apr 2015 15:42:54 +0200 Subject: [PATCH] increase test coverage --- README.md | 2 +- test/unit.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 66d391cf..c1dc8179 100644 --- a/README.md +++ b/README.md @@ -392,7 +392,7 @@ $ make $ ./json_unit =============================================================================== -All tests passed (4332 assertions in 18 test cases) +All tests passed (4463 assertions in 18 test cases) ``` For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). diff --git a/test/unit.cpp b/test/unit.cpp index 5b20218a..6c2aec6d 100644 --- a/test/unit.cpp +++ b/test/unit.cpp @@ -3022,6 +3022,18 @@ TEST_CASE("element access") { SECTION("erase with one valid iterator") { + SECTION("null") + { + { + json j; + CHECK_THROWS_AS(j.erase(j.begin()), std::runtime_error); + } + { + json j; + CHECK_THROWS_AS(j.erase(j.cbegin()), std::runtime_error); + } + } + SECTION("string") { { @@ -3140,6 +3152,18 @@ TEST_CASE("element access") SECTION("erase with two valid iterators") { + SECTION("null") + { + { + json j; + CHECK_THROWS_AS(j.erase(j.begin(), j.end()), std::runtime_error); + } + { + json j; + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cend()), std::runtime_error); + } + } + SECTION("string") { {