From 0f065edff6d741383ea1639fb6bbb8605e4e88d8 Mon Sep 17 00:00:00 2001 From: HenryLee Date: Wed, 7 Jun 2017 18:01:01 +1000 Subject: [PATCH] Revert a change in reverse iterator to pass the test cases --- src/json.hpp | 2 +- test/src/unit-iterators2.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 3fb89ea2..ee525c91 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -8686,7 +8686,7 @@ class basic_json /// access to successor reference operator[](difference_type n) const { - return base_iterator::operator[](n); + return *(this->operator+(n)); } /// return the key of an object iterator diff --git a/test/src/unit-iterators2.cpp b/test/src/unit-iterators2.cpp index 2be349b3..ae8ce687 100644 --- a/test/src/unit-iterators2.cpp +++ b/test/src/unit-iterators2.cpp @@ -833,15 +833,15 @@ TEST_CASE("iterators 2") auto it = j_object.rbegin(); CHECK_THROWS_AS(it[0], json::invalid_iterator); CHECK_THROWS_AS(it[1], json::invalid_iterator); - //CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); - //CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); + CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); + CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.crbegin(); CHECK_THROWS_AS(it[0], json::invalid_iterator); CHECK_THROWS_AS(it[1], json::invalid_iterator); - //CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); - //CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); + CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); + CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } } @@ -873,15 +873,15 @@ TEST_CASE("iterators 2") auto it = j_null.rbegin(); CHECK_THROWS_AS(it[0], json::invalid_iterator); CHECK_THROWS_AS(it[1], json::invalid_iterator); - //CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.214] cannot get value"); - //CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); + CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.214] cannot get value"); + CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } { auto it = j_null.crbegin(); CHECK_THROWS_AS(it[0], json::invalid_iterator); CHECK_THROWS_AS(it[1], json::invalid_iterator); - //CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.214] cannot get value"); - //CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); + CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.214] cannot get value"); + CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } }