From bbdfe7dea6457c96a329390fa7a558fe8359361d Mon Sep 17 00:00:00 2001 From: Ben Berman Date: Thu, 30 Aug 2018 12:35:51 -0400 Subject: [PATCH 1/3] Improve error messages for error 305 Addresses #1220 --- include/nlohmann/json.hpp | 12 ++++++------ single_include/nlohmann/json.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 1f39e3ec7..949df15ca 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3097,7 +3097,7 @@ class basic_json return m_value.array->operator[](idx); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); } /*! @@ -3127,7 +3127,7 @@ class basic_json return m_value.array->operator[](idx); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); } /*! @@ -3173,7 +3173,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -3215,7 +3215,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -3262,7 +3262,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -3305,7 +3305,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ac27d3d4c..e60eed887 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14204,7 +14204,7 @@ class basic_json return m_value.array->operator[](idx); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); } /*! @@ -14234,7 +14234,7 @@ class basic_json return m_value.array->operator[](idx); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()))); } /*! @@ -14280,7 +14280,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -14322,7 +14322,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -14369,7 +14369,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! @@ -14412,7 +14412,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); } /*! From ad053ef09c32a84a7792af97480e7542f4a167ed Mon Sep 17 00:00:00 2001 From: Ben Berman Date: Thu, 30 Aug 2018 13:19:09 -0400 Subject: [PATCH 2/3] Fix tests for improved error 305(hopefully) --- test/src/unit-element_access1.cpp | 26 ++++++++-------- test/src/unit-element_access2.cpp | 52 +++++++++++++++---------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/test/src/unit-element_access1.cpp b/test/src/unit-element_access1.cpp index 2954d696c..2b0c69d8a 100644 --- a/test/src/unit-element_access1.cpp +++ b/test/src/unit-element_access1.cpp @@ -195,7 +195,7 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_NOTHROW(j_nonarray[0]); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with null"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with null"); } SECTION("implicit transformation to properly filled array") @@ -212,8 +212,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with boolean"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with boolean"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with boolean"); } SECTION("string") @@ -222,8 +222,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with string"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with string"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with string"); } SECTION("object") @@ -232,8 +232,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with object"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with object"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with object"); } SECTION("number (integer)") @@ -242,8 +242,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with number"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with number"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); } SECTION("number (unsigned)") @@ -252,8 +252,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with number"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with number"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); } SECTION("number (floating-point)") @@ -262,8 +262,8 @@ TEST_CASE("element access 1") const json j_nonarray_const(j_nonarray); CHECK_THROWS_AS(j_nonarray[0], json::type_error&); CHECK_THROWS_AS(j_nonarray_const[0], json::type_error&); - CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with number"); - CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with number"); + CHECK_THROWS_WITH(j_nonarray[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); + CHECK_THROWS_WITH(j_nonarray_const[0], "[json.exception.type_error.305] cannot use operator[] with a numeric argument with number"); } } } diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index 41ec42bef..8707c472a 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -475,9 +475,9 @@ TEST_CASE("element access 2") CHECK_NOTHROW(j_nonobject2[json::object_t::key_type("foo")]); CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); - CHECK_THROWS_WITH(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with null"); + CHECK_THROWS_WITH(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a key-style argument with null"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with null"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with null"); } SECTION("boolean") @@ -489,13 +489,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); } SECTION("string") @@ -507,13 +507,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with string"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with string"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with string"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with string"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); } SECTION("array") @@ -525,12 +525,12 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with array"); - CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with array"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); + CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with array"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with array"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); } SECTION("number (integer)") @@ -542,13 +542,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); } SECTION("number (unsigned)") @@ -560,13 +560,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); } SECTION("number (floating-point)") @@ -578,13 +578,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with number"); + "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); } } } From 8f07ab6392c7b3eff1a16275d5a23ff4498ec702 Mon Sep 17 00:00:00 2001 From: Ben Berman Date: Mon, 17 Sep 2018 15:36:38 -0400 Subject: [PATCH 3/3] Replace "key-style argument" with "string argument" --- include/nlohmann/json.hpp | 8 ++--- single_include/nlohmann/json.hpp | 8 ++--- test/src/unit-element_access2.cpp | 52 +++++++++++++++---------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 949df15ca..21421f8b2 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3173,7 +3173,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -3215,7 +3215,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -3262,7 +3262,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -3305,7 +3305,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index e60eed887..e19309595 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14280,7 +14280,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -14322,7 +14322,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -14369,7 +14369,7 @@ class basic_json return m_value.object->operator[](key); } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! @@ -14412,7 +14412,7 @@ class basic_json return m_value.object->find(key)->second; } - JSON_THROW(type_error::create(305, "cannot use operator[] with a key-style argument with " + std::string(type_name()))); + JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()))); } /*! diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index 8707c472a..287a1a187 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -475,9 +475,9 @@ TEST_CASE("element access 2") CHECK_NOTHROW(j_nonobject2[json::object_t::key_type("foo")]); CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); - CHECK_THROWS_WITH(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a key-style argument with null"); + CHECK_THROWS_WITH(j_const_nonobject["foo"], "[json.exception.type_error.305] cannot use operator[] with a string argument with null"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with null"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with null"); } SECTION("boolean") @@ -489,13 +489,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with boolean"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with boolean"); } SECTION("string") @@ -507,13 +507,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with string"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with string"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with string"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with string"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with string"); } SECTION("array") @@ -525,12 +525,12 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); - CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with array"); + CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with a string argument with array"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with array"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with array"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with array"); } SECTION("number (integer)") @@ -542,13 +542,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); } SECTION("number (unsigned)") @@ -560,13 +560,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); } SECTION("number (floating-point)") @@ -578,13 +578,13 @@ TEST_CASE("element access 2") CHECK_THROWS_AS(j_const_nonobject["foo"], json::type_error&); CHECK_THROWS_AS(j_const_nonobject[json::object_t::key_type("foo")], json::type_error&); CHECK_THROWS_WITH(j_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject["foo"], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); CHECK_THROWS_WITH(j_const_nonobject[json::object_t::key_type("foo")], - "[json.exception.type_error.305] cannot use operator[] with a key-style argument with number"); + "[json.exception.type_error.305] cannot use operator[] with a string argument with number"); } } }