From 8fcd01631f9383c6a8a2ff6a6286e78b2a96b5f4 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 8 Mar 2017 16:39:17 +0100 Subject: [PATCH] :white_check_mark: improved test coverage Tests for parse_error.109 were missing. --- test/src/unit-json_pointer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index a6f811eb..d14261a0 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -272,6 +272,20 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(j["/one"_json_pointer] = 1, json::parse_error); CHECK_THROWS_WITH(j["/one"_json_pointer] = 1, "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + CHECK_THROWS_AS(j_const["/one"_json_pointer] == 1, json::parse_error); + CHECK_THROWS_WITH(j_const["/one"_json_pointer] == 1, + "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + + CHECK_THROWS_AS(j.at("/one"_json_pointer) = 1, json::parse_error); + CHECK_THROWS_WITH(j.at("/one"_json_pointer) = 1, + "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + CHECK_THROWS_AS(j_const.at("/one"_json_pointer) == 1, json::parse_error); + CHECK_THROWS_WITH(j_const.at("/one"_json_pointer) == 1, + "[json.exception.parse_error.109] parse error: array index 'one' is not a number"); + + CHECK_THROWS_AS(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), json::parse_error); + CHECK_THROWS_WITH(json({{"/list/0", 1}, {"/list/1", 2}, {"/list/three", 3}}).unflatten(), + "[json.exception.parse_error.109] parse error: array index 'three' is not a number"); // assign to "-" j["/-"_json_pointer] = 99;