From ebc6849b7171ea2d9ea5dac3d338ecf9b23d6f19 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 29 Dec 2017 16:53:04 +0100 Subject: [PATCH] :white_check_mark: added test for #894 --- test/src/unit-json_pointer.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index 4af379c4..77851f6a 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -55,6 +55,15 @@ TEST_CASE("JSON pointers") CHECK_THROWS_AS(p.pop_back(), json::out_of_range&); CHECK_THROWS_WITH(p.pop_back(), "[json.exception.out_of_range.405] JSON pointer has no parent"); + + SECTION("array index error") + { + json v = {1, 2, 3, 4}; + json::json_pointer ptr("/10e"); + CHECK_THROWS_AS(v[ptr], json::out_of_range); + CHECK_THROWS_WITH(v[ptr], + "[json.exception.out_of_range.404] unresolved reference token '10e'"); + } } SECTION("examples from RFC 6901")