diff --git a/Makefile b/Makefile index 5a232cf0..95b2063b 100644 --- a/Makefile +++ b/Makefile @@ -88,6 +88,7 @@ pedantic_gcc: -Wformat-signedness \ -Wformat-truncation=2 \ -Wformat=2 \ + -Wno-ignored-qualifiers \ -Wimplicit-fallthrough=5 \ -Wlogical-op \ -Wmissing-declarations \ diff --git a/src/json.hpp b/src/json.hpp index 86664171..918a646b 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -2268,7 +2268,7 @@ class basic_json object | `{}` array | `[]` - @param[in] value_type the type of the value to create + @param[in] v the type of the value to create @complexity Constant. @@ -2277,8 +2277,8 @@ class basic_json @since version 1.0.0 */ - basic_json(const value_t value_type) - : m_type(value_type), m_value(value_type) + basic_json(const value_t v) + : m_type(v), m_value(v) { assert_invariant(); } @@ -12881,12 +12881,14 @@ scan_number_done: { // using "uninitialized" to avoid "expected" message expect(lexer::token_type::uninitialized); + break; } default: { // the last token was unexpected; we expected a value expect(lexer::token_type::literal_or_value); + break; } } diff --git a/test/src/unit-algorithms.cpp b/test/src/unit-algorithms.cpp index 494ea83e..5a106b6a 100644 --- a/test/src/unit-algorithms.cpp +++ b/test/src/unit-algorithms.cpp @@ -240,7 +240,7 @@ TEST_CASE("algorithms") SECTION("sorting an object") { json j({{"one", 1}, {"two", 2}}); - CHECK_THROWS_AS(std::sort(j.begin(), j.end()), json::invalid_iterator); + CHECK_THROWS_AS(std::sort(j.begin(), j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(std::sort(j.begin(), j.end()), "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } diff --git a/test/src/unit-allocator.cpp b/test/src/unit-allocator.cpp index 903d5950..d2423a48 100644 --- a/test/src/unit-allocator.cpp +++ b/test/src/unit-allocator.cpp @@ -59,7 +59,7 @@ TEST_CASE("bad_alloc") bad_allocator>; // creating an object should throw - CHECK_THROWS_AS(bad_json(bad_json::value_t::object), std::bad_alloc); + CHECK_THROWS_AS(bad_json(bad_json::value_t::object), std::bad_alloc&); } } @@ -143,7 +143,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::object; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).object)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("array") @@ -152,7 +152,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::array; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).array)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } SECTION("string") @@ -161,7 +161,7 @@ TEST_CASE("controlled bad_alloc") auto t = my_json::value_t::string; CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(t).string)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value(t), std::bad_alloc&); next_construct_fails = false; } } @@ -172,7 +172,7 @@ TEST_CASE("controlled bad_alloc") my_json::string_t v("foo"); CHECK_NOTHROW(my_allocator_clean_up(my_json::json_value(v).string)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value(v), std::bad_alloc&); next_construct_fails = false; } @@ -183,7 +183,7 @@ TEST_CASE("controlled bad_alloc") my_json::object_t v {{"foo", "bar"}}; CHECK_NOTHROW(my_json::json_value j(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc&); next_construct_fails = false; } */ @@ -194,7 +194,7 @@ TEST_CASE("controlled bad_alloc") my_json::array_t v = {"foo", "bar", "baz"}; CHECK_NOTHROW(my_json::json_value j(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc); + CHECK_THROWS_AS(my_json::json_value j(v), std::bad_alloc&); next_construct_fails = false; } */ @@ -208,7 +208,7 @@ TEST_CASE("controlled bad_alloc") std::map v {{"foo", "bar"}}; CHECK_NOTHROW(my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(v), std::bad_alloc); + CHECK_THROWS_AS(my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -218,7 +218,7 @@ TEST_CASE("controlled bad_alloc") std::vector v {"foo", "bar", "baz"}; CHECK_NOTHROW(my_json(v)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(v), std::bad_alloc); + CHECK_THROWS_AS(my_json(v), std::bad_alloc&); next_construct_fails = false; } @@ -227,7 +227,7 @@ TEST_CASE("controlled bad_alloc") next_construct_fails = false; CHECK_NOTHROW(my_json("foo")); next_construct_fails = true; - CHECK_THROWS_AS(my_json("foo"), std::bad_alloc); + CHECK_THROWS_AS(my_json("foo"), std::bad_alloc&); next_construct_fails = false; } @@ -237,7 +237,7 @@ TEST_CASE("controlled bad_alloc") std::string s("foo"); CHECK_NOTHROW(my_json(s)); next_construct_fails = true; - CHECK_THROWS_AS(my_json(s), std::bad_alloc); + CHECK_THROWS_AS(my_json(s), std::bad_alloc&); next_construct_fails = false; } } diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index 5638d490..5ab6a2e2 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -1143,21 +1143,21 @@ TEST_CASE("CBOR") { SECTION("too short byte vector") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0x18})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x19})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x19, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x18})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x19})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x19, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1a, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(std::vector({0x18})), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); @@ -1195,10 +1195,10 @@ TEST_CASE("CBOR") { SECTION("concrete examples") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0x1c})), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(std::vector({0x1c})), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(std::vector({0x1c})), "[json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0x1c"); - CHECK_THROWS_AS(json::from_cbor(std::vector({0xf8})), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(std::vector({0xf8})), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(std::vector({0xf8})), "[json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0xf8"); } @@ -1249,14 +1249,14 @@ TEST_CASE("CBOR") 0xf8 }) { - CHECK_THROWS_AS(json::from_cbor(std::vector({static_cast(byte)})), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(std::vector({static_cast(byte)})), json::parse_error&); } } } SECTION("invalid string in map") { - CHECK_THROWS_AS(json::from_cbor(std::vector({0xa1, 0xff, 0x01})), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(std::vector({0xa1, 0xff, 0x01})), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(std::vector({0xa1, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at 2: expected a CBOR string; last byte: 0xff"); } diff --git a/test/src/unit-class_const_iterator.cpp b/test/src/unit-class_const_iterator.cpp index 26b31265..78179882 100644 --- a/test/src/unit-class_const_iterator.cpp +++ b/test/src/unit-class_const_iterator.cpp @@ -147,7 +147,7 @@ TEST_CASE("const_iterator class") { json j(json::value_t::null); json::const_iterator it = j.cbegin(); - CHECK_THROWS_AS(*it, json::invalid_iterator); + CHECK_THROWS_AS(*it, json::invalid_iterator&); CHECK_THROWS_WITH(*it, "[json.exception.invalid_iterator.214] cannot get value"); } @@ -157,7 +157,7 @@ TEST_CASE("const_iterator class") json::const_iterator it = j.cbegin(); CHECK(*it == json(17)); it = j.cend(); - CHECK_THROWS_AS(*it, json::invalid_iterator); + CHECK_THROWS_AS(*it, json::invalid_iterator&); CHECK_THROWS_WITH(*it, "[json.exception.invalid_iterator.214] cannot get value"); } @@ -182,7 +182,7 @@ TEST_CASE("const_iterator class") { json j(json::value_t::null); json::const_iterator it = j.cbegin(); - CHECK_THROWS_AS(it->type_name(), json::invalid_iterator); + CHECK_THROWS_AS(it->type_name(), json::invalid_iterator&); CHECK_THROWS_WITH(it->type_name(), "[json.exception.invalid_iterator.214] cannot get value"); } @@ -192,7 +192,7 @@ TEST_CASE("const_iterator class") json::const_iterator it = j.cbegin(); CHECK(it->type_name() == "number"); it = j.cend(); - CHECK_THROWS_AS(it->type_name(), json::invalid_iterator); + CHECK_THROWS_AS(it->type_name(), json::invalid_iterator&); CHECK_THROWS_WITH(it->type_name(), "[json.exception.invalid_iterator.214] cannot get value"); } diff --git a/test/src/unit-class_iterator.cpp b/test/src/unit-class_iterator.cpp index 6ff3c369..7057d967 100644 --- a/test/src/unit-class_iterator.cpp +++ b/test/src/unit-class_iterator.cpp @@ -131,7 +131,7 @@ TEST_CASE("iterator class") { json j(json::value_t::null); json::iterator it = j.begin(); - CHECK_THROWS_AS(*it, json::invalid_iterator); + CHECK_THROWS_AS(*it, json::invalid_iterator&); CHECK_THROWS_WITH(*it, "[json.exception.invalid_iterator.214] cannot get value"); } @@ -141,7 +141,7 @@ TEST_CASE("iterator class") json::iterator it = j.begin(); CHECK(*it == json(17)); it = j.end(); - CHECK_THROWS_AS(*it, json::invalid_iterator); + CHECK_THROWS_AS(*it, json::invalid_iterator&); CHECK_THROWS_WITH(*it, "[json.exception.invalid_iterator.214] cannot get value"); } @@ -166,7 +166,7 @@ TEST_CASE("iterator class") { json j(json::value_t::null); json::iterator it = j.begin(); - CHECK_THROWS_AS(it->type_name(), json::invalid_iterator); + CHECK_THROWS_AS(it->type_name(), json::invalid_iterator&); CHECK_THROWS_WITH(it->type_name(), "[json.exception.invalid_iterator.214] cannot get value"); } @@ -176,7 +176,7 @@ TEST_CASE("iterator class") json::iterator it = j.begin(); CHECK(it->type_name() == "number"); it = j.end(); - CHECK_THROWS_AS(it->type_name(), json::invalid_iterator); + CHECK_THROWS_AS(it->type_name(), json::invalid_iterator&); CHECK_THROWS_WITH(it->type_name(), "[json.exception.invalid_iterator.214] cannot get value"); } diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index ed55eba5..7a8378a7 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -89,56 +89,56 @@ TEST_CASE("parser class") SECTION("errors") { // error: tab in string - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\t\""))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\t\""))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\"\t\""))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"'"); // error: newline in string - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\n\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\r\""))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\n\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\r\""))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\"\n\""))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\"\r\""))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"'"); // error: backspace in string - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\b\""))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\b\""))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\"\b\""))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"'"); // improve code coverage - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\uFF01"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[-4:1,]"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\uFF01"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[-4:1,]"))).parse(), json::parse_error&); // unescaped control characters - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x00\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x01\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x02\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x03\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x04\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x05\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x06\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x07\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x08\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x09\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0a\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0b\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0c\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0d\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0e\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0f\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x10\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x11\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x12\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x13\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x14\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x15\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x16\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x17\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x18\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x19\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1a\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1b\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1c\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1d\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1e\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1f\""))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x00\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x01\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x02\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x03\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x04\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x05\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x06\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x07\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x08\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x09\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0a\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0b\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0c\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0d\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0e\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x0f\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x10\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x11\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x12\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x13\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x14\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x15\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x16\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x17\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x18\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x19\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1a\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1b\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1c\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1d\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1e\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\x1f\""))).parse(), json::parse_error&); } SECTION("escaped") @@ -277,33 +277,33 @@ TEST_CASE("parser class") SECTION("overflow") { // overflows during parsing yield an exception - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1.18973e+4932"))).parse() == json(), json::out_of_range); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1.18973e+4932"))).parse() == json(), json::out_of_range&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("1.18973e+4932"))).parse() == json(), "[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'"); } SECTION("invalid numbers") { - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("01"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("--1"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E-"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1.E1"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-1E"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E#"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E-#"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0#"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0.0:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0.0Z"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E123:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0e0-:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0e-:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0f"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("01"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("--1"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E-"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1.E1"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-1E"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E#"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E-#"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0#"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0.0:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0.0Z"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0E123:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0e0-:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0e-:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0f"))).parse(), json::parse_error&); // numbers must not begin with "+" - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("+1"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("+0"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("+1"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("+0"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("01"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - unexpected number literal; expected end of input"); @@ -608,20 +608,20 @@ TEST_CASE("parser class") SECTION("parse errors") { // unexpected end of number - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("0."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("--"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("0.:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("e."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e/"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e:"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E."))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E/"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E:"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("0."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("--"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-0."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("-:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("0.:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("e."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e/"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1e:"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E."))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E/"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("1E:"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("0."))).parse(), "[json.exception.parse_error.101] parse error at 3: syntax error - invalid number; expected digit after '.'; last read: '0.'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("-"))).parse(), @@ -652,9 +652,9 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 3: syntax error - invalid number; expected '+', '-', or digit after exponent; last read: '1E:'"); // unexpected end of null - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("n"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("nu"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("nul"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("n"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("nu"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("nul"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("n"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 'n'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("nu"))).parse(), @@ -663,9 +663,9 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 4: syntax error - invalid literal; last read: 'nul'"); // unexpected end of true - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("t"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("tr"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("tru"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("t"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("tr"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("tru"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("t"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 't'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("tr"))).parse(), @@ -674,10 +674,10 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 4: syntax error - invalid literal; last read: 'tru'"); // unexpected end of false - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("f"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fa"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fal"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fals"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("f"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fa"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fal"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("fals"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("f"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 'f'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("fa"))).parse(), @@ -688,11 +688,11 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 5: syntax error - invalid literal; last read: 'fals'"); // missing/unexpected end of array - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("["))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1,"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1,]"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("]"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("["))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1,"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[1,]"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("]"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("["))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - unexpected end of input; expected '[', '{', or a literal"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("[1"))).parse(), @@ -705,12 +705,12 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected ']'; expected '[', '{', or a literal"); // missing/unexpected end of object - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":}"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":1,}"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("}"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":}"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{\"foo\":1,}"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("}"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("{"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - unexpected end of input; expected string literal"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("{\"foo\""))).parse(), @@ -725,16 +725,16 @@ TEST_CASE("parser class") "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected '}'; expected '[', '{', or a literal"); // missing/unexpected end of string - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u0\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u01\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u012\""))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u0"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u01"))).parse(), json::parse_error); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u012"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u0\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u01\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u012\""))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u0"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u01"))).parse(), json::parse_error&); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("\"\\u012"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\""))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: missing closing quote; last read: '\"'"); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("\"\\\""))).parse(), @@ -786,7 +786,7 @@ TEST_CASE("parser class") // any other combination of backslash and character is invalid default: { - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s.c_str()))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s.c_str()))).parse(), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) { @@ -862,7 +862,7 @@ TEST_CASE("parser class") else { CAPTURE(s1); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s1.c_str()))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s1.c_str()))).parse(), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) { @@ -871,7 +871,7 @@ TEST_CASE("parser class") } CAPTURE(s2); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s2.c_str()))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s2.c_str()))).parse(), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) { @@ -880,7 +880,7 @@ TEST_CASE("parser class") } CAPTURE(s3); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s3.c_str()))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s3.c_str()))).parse(), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) { @@ -889,7 +889,7 @@ TEST_CASE("parser class") } CAPTURE(s4); - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s4.c_str()))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string(s4.c_str()))).parse(), json::parse_error&); // only check error message if c is not a control character if (c > 0x1f) { @@ -901,13 +901,13 @@ TEST_CASE("parser class") } // missing part of a surrogate pair - CHECK_THROWS_AS(json::parse("\"\\uD80C\""), json::parse_error); + CHECK_THROWS_AS(json::parse("\"\\uD80C\""), json::parse_error&); CHECK_THROWS_WITH(json::parse("\"\\uD80C\""), "[json.exception.parse_error.101] parse error at 8: syntax error - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\"'"); // invalid surrogate pair - CHECK_THROWS_AS(json::parse("\"\\uD80C\\uD80C\""), json::parse_error); - CHECK_THROWS_AS(json::parse("\"\\uD80C\\u0000\""), json::parse_error); - CHECK_THROWS_AS(json::parse("\"\\uD80C\\uFFFF\""), json::parse_error); + CHECK_THROWS_AS(json::parse("\"\\uD80C\\uD80C\""), json::parse_error&); + CHECK_THROWS_AS(json::parse("\"\\uD80C\\u0000\""), json::parse_error&); + CHECK_THROWS_AS(json::parse("\"\\uD80C\\uFFFF\""), json::parse_error&); CHECK_THROWS_WITH(json::parse("\"\\uD80C\\uD80C\""), "[json.exception.parse_error.101] parse error at 13: syntax error - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD80C\\uD80C'"); CHECK_THROWS_WITH(json::parse("\"\\uD80C\\u0000\""), @@ -1102,11 +1102,11 @@ TEST_CASE("parser class") SECTION("tests found by mutate++") { // test case to make sure no comma preceeds the first key - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{,\"key\": false}"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("{,\"key\": false}"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("{,\"key\": false}"))).parse(), "[json.exception.parse_error.101] parse error at 2: syntax error - unexpected ','; expected string literal"); // test case to make sure an object is properly closed - CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[{\"key\": false true]"))).parse(), json::parse_error); + CHECK_THROWS_AS(json::parser(json::input_adapter::create(std::string("[{\"key\": false true]"))).parse(), json::parse_error&); CHECK_THROWS_WITH(json::parser(json::input_adapter::create(std::string("[{\"key\": false true]"))).parse(), "[json.exception.parse_error.101] parse error at 19: syntax error - unexpected true literal; expected '}'"); diff --git a/test/src/unit-constructor1.cpp b/test/src/unit-constructor1.cpp index 9dbf4540..7822b634 100644 --- a/test/src/unit-constructor1.cpp +++ b/test/src/unit-constructor1.cpp @@ -1017,7 +1017,7 @@ TEST_CASE("constructors") SECTION("object with error") { CHECK_THROWS_AS(json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), - json::type_error); + json::type_error&); CHECK_THROWS_WITH(json::object({ {"one", 1}, {"two", 1u}, {"three", 2.2}, {"four", false}, 13 }), "[json.exception.type_error.301] cannot create object from initializer list"); } @@ -1091,16 +1091,16 @@ TEST_CASE("constructors") { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_AS(json(jobject.begin(), jobject2.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(jobject2.begin(), jobject.end()), json::invalid_iterator); + CHECK_THROWS_AS(json(jobject.begin(), jobject2.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(jobject2.begin(), jobject.end()), json::invalid_iterator&); CHECK_THROWS_WITH(json(jobject.begin(), jobject2.end()), "[json.exception.invalid_iterator.201] iterators are not compatible"); CHECK_THROWS_WITH(json(jobject2.begin(), jobject.end()), "[json.exception.invalid_iterator.201] iterators are not compatible"); } { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_AS(json(jobject.cbegin(), jobject2.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(jobject2.cbegin(), jobject.cend()), json::invalid_iterator); + CHECK_THROWS_AS(json(jobject.cbegin(), jobject2.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(jobject2.cbegin(), jobject.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(json(jobject.cbegin(), jobject2.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible"); CHECK_THROWS_WITH(json(jobject2.cbegin(), jobject.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible"); } @@ -1156,16 +1156,16 @@ TEST_CASE("constructors") { json jarray = {1, 2, 3, 4}; json jarray2 = {2, 3, 4, 5}; - CHECK_THROWS_AS(json(jarray.begin(), jarray2.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(jarray2.begin(), jarray.end()), json::invalid_iterator); + CHECK_THROWS_AS(json(jarray.begin(), jarray2.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(jarray2.begin(), jarray.end()), json::invalid_iterator&); CHECK_THROWS_WITH(json(jarray.begin(), jarray2.end()), "[json.exception.invalid_iterator.201] iterators are not compatible"); CHECK_THROWS_WITH(json(jarray2.begin(), jarray.end()), "[json.exception.invalid_iterator.201] iterators are not compatible"); } { json jarray = {1, 2, 3, 4}; json jarray2 = {2, 3, 4, 5}; - CHECK_THROWS_AS(json(jarray.cbegin(), jarray2.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(jarray2.cbegin(), jarray.cend()), json::invalid_iterator); + CHECK_THROWS_AS(json(jarray.cbegin(), jarray2.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(jarray2.cbegin(), jarray.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(json(jarray.cbegin(), jarray2.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible"); CHECK_THROWS_WITH(json(jarray2.cbegin(), jarray.cend()), "[json.exception.invalid_iterator.201] iterators are not compatible"); } @@ -1180,13 +1180,13 @@ TEST_CASE("constructors") { { json j; - CHECK_THROWS_AS(json(j.begin(), j.end()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.begin(), j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.begin(), j.end()), "[json.exception.invalid_iterator.206] cannot construct with iterators from null"); } { json j; - CHECK_THROWS_AS(json(j.cbegin(), j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cbegin(), j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cbegin(), j.cend()), "[json.exception.invalid_iterator.206] cannot construct with iterators from null"); } @@ -1269,15 +1269,15 @@ TEST_CASE("constructors") { { json j = "foo"; - CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = "bar"; - CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -1287,15 +1287,15 @@ TEST_CASE("constructors") { { json j = false; - CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = true; - CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -1305,15 +1305,15 @@ TEST_CASE("constructors") { { json j = 17; - CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 17; - CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -1323,15 +1323,15 @@ TEST_CASE("constructors") { { json j = 17u; - CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 17u; - CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -1341,15 +1341,15 @@ TEST_CASE("constructors") { { json j = 23.42; - CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 23.42; - CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(json(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(json(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } diff --git a/test/src/unit-conversions.cpp b/test/src/unit-conversions.cpp index 0940ec51..59c8e53f 100644 --- a/test/src/unit-conversions.cpp +++ b/test/src/unit-conversions.cpp @@ -78,13 +78,13 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-object type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be object, but is null"); @@ -161,7 +161,7 @@ TEST_CASE("value conversion") std::forward_list a = j.get>(); CHECK(json(a) == j); - CHECK_THROWS_AS(json(json::value_t::null).get>(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get>(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get>(), "[json.exception.type_error.302] type must be array, but is null"); } @@ -171,7 +171,7 @@ TEST_CASE("value conversion") std::vector a = j.get>(); CHECK(json(a) == j); - CHECK_THROWS_AS(json(json::value_t::null).get>(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get>(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get>(), "[json.exception.type_error.302] type must be array, but is null"); @@ -180,7 +180,7 @@ TEST_CASE("value conversion") { // making the call to from_json throw in order to check capacity std::vector v; - CHECK_THROWS_AS(nlohmann::from_json(j, v), json::type_error); + CHECK_THROWS_AS(nlohmann::from_json(j, v), json::type_error&); CHECK(v.capacity() == j.size()); // make sure all values are properly copied @@ -212,13 +212,13 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-array type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::object).get>(), "[json.exception.type_error.302] type must be array, but is object"); @@ -294,13 +294,13 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-string type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be string, but is null"); @@ -356,13 +356,13 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-string type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_integer).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_unsigned).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::number_float).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be boolean, but is null"); @@ -612,11 +612,11 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-number type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be number, but is null"); @@ -871,11 +871,11 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-string type") { - CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error); - CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error); + CHECK_THROWS_AS(json(json::value_t::null).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::object).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::array).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::string).get(), json::type_error&); + CHECK_THROWS_AS(json(json::value_t::boolean).get(), json::type_error&); CHECK_THROWS_WITH(json(json::value_t::null).get(), "[json.exception.type_error.302] type must be number, but is null"); @@ -977,7 +977,7 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-object type") { - CHECK_THROWS_AS((json().get>()), json::type_error); + CHECK_THROWS_AS((json().get>()), json::type_error&); CHECK_THROWS_WITH((json().get>()), "[json.exception.type_error.302] type must be object, but is null"); } } @@ -1046,10 +1046,10 @@ TEST_CASE("value conversion") SECTION("exception in case of a non-object type") { - CHECK_THROWS_AS((json().get>()), json::type_error); - CHECK_THROWS_AS((json().get>()), json::type_error); - CHECK_THROWS_AS((json().get>()), json::type_error); - CHECK_THROWS_AS((json().get>()), json::type_error); + CHECK_THROWS_AS((json().get>()), json::type_error&); + CHECK_THROWS_AS((json().get>()), json::type_error&); + CHECK_THROWS_AS((json().get>()), json::type_error&); + CHECK_THROWS_AS((json().get>()), json::type_error&); // does type really must be an array? or it rather must not be null? // that's what I thought when other test like this one broke diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 48ec91c0..3de8f156 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -95,7 +95,7 @@ TEST_CASE("deserialization") ss1 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss2 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss3 << "[\"foo\",1,2,3,false,{\"one\":1}"; - CHECK_THROWS_AS(json::parse(ss1), json::parse_error); + CHECK_THROWS_AS(json::parse(ss1), json::parse_error&); CHECK_THROWS_WITH(json::parse(ss2), "[json.exception.parse_error.101] parse error at 29: syntax error - unexpected end of input; expected ']'"); CHECK(not json::accept(ss3)); @@ -104,7 +104,7 @@ TEST_CASE("deserialization") SECTION("string") { json::string_t s = "[\"foo\",1,2,3,false,{\"one\":1}"; - CHECK_THROWS_AS(json::parse(s), json::parse_error); + CHECK_THROWS_AS(json::parse(s), json::parse_error&); CHECK_THROWS_WITH(json::parse(s), "[json.exception.parse_error.101] parse error at 29: syntax error - unexpected end of input; expected ']'"); CHECK(not json::accept(s)); @@ -116,7 +116,7 @@ TEST_CASE("deserialization") ss1 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss2 << "[\"foo\",1,2,3,false,{\"one\":1}"; json j; - CHECK_THROWS_AS(j << ss1, json::parse_error); + CHECK_THROWS_AS(j << ss1, json::parse_error&); CHECK_THROWS_WITH(j << ss2, "[json.exception.parse_error.101] parse error at 29: syntax error - unexpected end of input; expected ']'"); } @@ -127,14 +127,14 @@ TEST_CASE("deserialization") ss1 << "[\"foo\",1,2,3,false,{\"one\":1}"; ss2 << "[\"foo\",1,2,3,false,{\"one\":1}"; json j; - CHECK_THROWS_AS(ss1 >> j, json::parse_error); + CHECK_THROWS_AS(ss1 >> j, json::parse_error&); CHECK_THROWS_WITH(ss2 >> j, "[json.exception.parse_error.101] parse error at 29: syntax error - unexpected end of input; expected ']'"); } SECTION("user-defined string literal") { - CHECK_THROWS_AS("[\"foo\",1,2,3,false,{\"one\":1}"_json, json::parse_error); + CHECK_THROWS_AS("[\"foo\",1,2,3,false,{\"one\":1}"_json, json::parse_error&); CHECK_THROWS_WITH("[\"foo\",1,2,3,false,{\"one\":1}"_json, "[json.exception.parse_error.101] parse error at 29: syntax error - unexpected end of input; expected ']'"); } @@ -195,7 +195,7 @@ TEST_CASE("deserialization") SECTION("empty container") { std::vector v; - CHECK_THROWS_AS(json::parse(v), json::parse_error); + CHECK_THROWS_AS(json::parse(v), json::parse_error&); CHECK(not json::accept(v)); } } @@ -247,7 +247,7 @@ TEST_CASE("deserialization") SECTION("with empty range") { std::vector v; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } } @@ -258,112 +258,112 @@ TEST_CASE("deserialization") SECTION("case 1") { uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u'}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 2") { uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1'}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 3") { uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', '\\', 'u', '1', '1', '1', '1', '1', '1', '1', '1'}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 4") { uint8_t v[] = {'\"', 'a', 'a', 'a', 'a', 'a', 'a', 'u', '1', '1', '1', '1', '1', '1', '1', '1', '\\'}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 5") { uint8_t v[] = {'\"', 0x7F, 0xC1}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 6") { uint8_t v[] = {'\"', 0x7F, 0xDF, 0x7F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 7") { uint8_t v[] = {'\"', 0x7F, 0xDF, 0xC0}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 8") { uint8_t v[] = {'\"', 0x7F, 0xE0, 0x9F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 9") { uint8_t v[] = {'\"', 0x7F, 0xEF, 0xC0}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 10") { uint8_t v[] = {'\"', 0x7F, 0xED, 0x7F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 11") { uint8_t v[] = {'\"', 0x7F, 0xF0, 0x8F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 12") { uint8_t v[] = {'\"', 0x7F, 0xF0, 0xC0}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 13") { uint8_t v[] = {'\"', 0x7F, 0xF3, 0x7F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 14") { uint8_t v[] = {'\"', 0x7F, 0xF3, 0xC0}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 15") { uint8_t v[] = {'\"', 0x7F, 0xF4, 0x7F}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } SECTION("case 16") { uint8_t v[] = {'{', '\"', '\"', ':', '1', '1'}; - CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error); + CHECK_THROWS_AS(json::parse(std::begin(v), std::end(v)), json::parse_error&); CHECK(not json::accept(std::begin(v), std::end(v))); } } diff --git a/test/src/unit-element_access1.cpp b/test/src/unit-element_access1.cpp index eb4a92cb..630b1a5e 100644 --- a/test/src/unit-element_access1.cpp +++ b/test/src/unit-element_access1.cpp @@ -63,8 +63,8 @@ TEST_CASE("element access 1") SECTION("access outside bounds") { - CHECK_THROWS_AS(j.at(8), json::out_of_range); - CHECK_THROWS_AS(j_const.at(8), json::out_of_range); + CHECK_THROWS_AS(j.at(8), json::out_of_range&); + CHECK_THROWS_AS(j_const.at(8), json::out_of_range&); CHECK_THROWS_WITH(j.at(8), "[json.exception.out_of_range.401] array index 8 is out of range"); @@ -78,8 +78,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::null); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with null"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with null"); @@ -89,8 +89,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::boolean); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with boolean"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with boolean"); @@ -100,8 +100,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::string); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with string"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with string"); @@ -111,8 +111,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::object); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with object"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with object"); @@ -122,8 +122,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_integer); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number"); @@ -133,8 +133,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_unsigned); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number"); @@ -144,8 +144,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_float); const json j_nonarray_const(j_nonarray); - CHECK_THROWS_AS(j_nonarray.at(0), json::type_error); - CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error); + CHECK_THROWS_AS(j_nonarray.at(0), json::type_error&); + CHECK_THROWS_AS(j_nonarray_const.at(0), json::type_error&); CHECK_THROWS_WITH(j_nonarray.at(0), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonarray_const.at(0), "[json.exception.type_error.304] cannot use at() with number"); @@ -193,7 +193,7 @@ TEST_CASE("element access 1") json j_nonarray(json::value_t::null); const json j_nonarray_const(j_nonarray); CHECK_NOTHROW(j_nonarray[0]); - CHECK_THROWS_AS(j_nonarray_const[0], json::type_error); + 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"); } @@ -209,8 +209,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::boolean); 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_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"); } @@ -219,8 +219,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::string); 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_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"); } @@ -229,8 +229,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::object); 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_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"); } @@ -239,8 +239,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_integer); 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_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"); } @@ -249,8 +249,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_unsigned); 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_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"); } @@ -259,8 +259,8 @@ TEST_CASE("element access 1") { json j_nonarray(json::value_t::number_float); 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_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"); } @@ -313,7 +313,7 @@ TEST_CASE("element access 1") } { json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; - CHECK_THROWS_AS(jarray.erase(8), json::out_of_range); + CHECK_THROWS_AS(jarray.erase(8), json::out_of_range&); CHECK_THROWS_WITH(jarray.erase(8), "[json.exception.out_of_range.401] array index 8 is out of range"); } @@ -408,10 +408,10 @@ TEST_CASE("element access 1") { json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; json jarray2 = {"foo", "bar"}; - CHECK_THROWS_AS(jarray.erase(jarray2.begin()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray.begin(), jarray2.end()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray.end()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray2.end()), json::invalid_iterator); + CHECK_THROWS_AS(jarray.erase(jarray2.begin()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray.begin(), jarray2.end()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray.end()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray2.end()), json::invalid_iterator&); CHECK_THROWS_WITH(jarray.erase(jarray2.begin()), "[json.exception.invalid_iterator.202] iterator does not fit current value"); @@ -425,10 +425,10 @@ TEST_CASE("element access 1") { json jarray = {1, 1u, true, nullptr, "string", 42.23, json::object(), {1, 2, 3}}; json jarray2 = {"foo", "bar"}; - CHECK_THROWS_AS(jarray.erase(jarray2.cbegin()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray.cbegin(), jarray2.cend()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray.cend()), json::invalid_iterator); - CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray2.cend()), json::invalid_iterator); + CHECK_THROWS_AS(jarray.erase(jarray2.cbegin()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray.cbegin(), jarray2.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray2.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(jarray.erase(jarray2.cbegin()), "[json.exception.invalid_iterator.202] iterator does not fit current value"); @@ -447,7 +447,7 @@ TEST_CASE("element access 1") SECTION("null") { json j_nonobject(json::value_t::null); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with null"); } @@ -455,7 +455,7 @@ TEST_CASE("element access 1") SECTION("boolean") { json j_nonobject(json::value_t::boolean); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with boolean"); } @@ -463,7 +463,7 @@ TEST_CASE("element access 1") SECTION("string") { json j_nonobject(json::value_t::string); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with string"); } @@ -471,7 +471,7 @@ TEST_CASE("element access 1") SECTION("object") { json j_nonobject(json::value_t::object); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with object"); } @@ -479,7 +479,7 @@ TEST_CASE("element access 1") SECTION("number (integer)") { json j_nonobject(json::value_t::number_integer); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with number"); } @@ -487,7 +487,7 @@ TEST_CASE("element access 1") SECTION("number (unsigned)") { json j_nonobject(json::value_t::number_unsigned); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with number"); } @@ -495,7 +495,7 @@ TEST_CASE("element access 1") SECTION("number (floating-point)") { json j_nonobject(json::value_t::number_float); - CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase(0), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase(0), "[json.exception.type_error.307] cannot use erase() with number"); } @@ -511,15 +511,15 @@ TEST_CASE("element access 1") { { json j; - CHECK_THROWS_AS(j.front(), json::invalid_iterator); - CHECK_THROWS_AS(j.back(), json::invalid_iterator); + CHECK_THROWS_AS(j.front(), json::invalid_iterator&); + CHECK_THROWS_AS(j.back(), json::invalid_iterator&); CHECK_THROWS_WITH(j.front(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(j.back(), "[json.exception.invalid_iterator.214] cannot get value"); } { const json j{}; - CHECK_THROWS_AS(j.front(), json::invalid_iterator); - CHECK_THROWS_AS(j.back(), json::invalid_iterator); + CHECK_THROWS_AS(j.front(), json::invalid_iterator&); + CHECK_THROWS_AS(j.back(), json::invalid_iterator&); CHECK_THROWS_WITH(j.front(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(j.back(), "[json.exception.invalid_iterator.214] cannot get value"); } @@ -602,13 +602,13 @@ TEST_CASE("element access 1") { { json j; - CHECK_THROWS_AS(j.erase(j.begin()), json::type_error); + CHECK_THROWS_AS(j.erase(j.begin()), json::type_error&); CHECK_THROWS_WITH(j.erase(j.begin()), "[json.exception.type_error.307] cannot use erase() with null"); } { json j; - CHECK_THROWS_AS(j.erase(j.cbegin()), json::type_error); + CHECK_THROWS_AS(j.erase(j.cbegin()), json::type_error&); CHECK_THROWS_WITH(j.erase(j.begin()), "[json.exception.type_error.307] cannot use erase() with null"); } @@ -701,13 +701,13 @@ TEST_CASE("element access 1") { { json j = "foo"; - CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range"); } { json j = "bar"; - CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range"); } @@ -717,13 +717,13 @@ TEST_CASE("element access 1") { { json j = false; - CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range"); } { json j = true; - CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range"); } @@ -733,13 +733,13 @@ TEST_CASE("element access 1") { { json j = 17; - CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range"); } { json j = 17; - CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range"); } @@ -749,13 +749,13 @@ TEST_CASE("element access 1") { { json j = 17u; - CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range"); } { json j = 17u; - CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range"); } @@ -765,13 +765,13 @@ TEST_CASE("element access 1") { { json j = 23.42; - CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range"); } { json j = 23.42; - CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range"); } @@ -784,13 +784,13 @@ TEST_CASE("element access 1") { { json j; - CHECK_THROWS_AS(j.erase(j.begin(), j.end()), json::type_error); + CHECK_THROWS_AS(j.erase(j.begin(), j.end()), json::type_error&); CHECK_THROWS_WITH(j.erase(j.begin(), j.end()), "[json.exception.type_error.307] cannot use erase() with null"); } { json j; - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cend()), json::type_error); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cend()), json::type_error&); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cend()), "[json.exception.type_error.307] cannot use erase() with null"); } @@ -883,15 +883,15 @@ TEST_CASE("element access 1") { { json j = "foo"; - CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = "bar"; - CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -901,15 +901,15 @@ TEST_CASE("element access 1") { { json j = false; - CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = true; - CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -919,15 +919,15 @@ TEST_CASE("element access 1") { { json j = 17; - CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 17; - CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -937,15 +937,15 @@ TEST_CASE("element access 1") { { json j = 17u; - CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 17u; - CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } @@ -955,15 +955,15 @@ TEST_CASE("element access 1") { { json j = 23.42; - CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.end(), j.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "[json.exception.invalid_iterator.204] iterators out of range"); } { json j = 23.42; - CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator); - CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator); + CHECK_THROWS_AS(j.erase(j.cend(), j.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), json::invalid_iterator&); CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "[json.exception.invalid_iterator.204] iterators out of range"); CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "[json.exception.invalid_iterator.204] iterators out of range"); } diff --git a/test/src/unit-element_access2.cpp b/test/src/unit-element_access2.cpp index ec03507e..5950349b 100644 --- a/test/src/unit-element_access2.cpp +++ b/test/src/unit-element_access2.cpp @@ -63,8 +63,8 @@ TEST_CASE("element access 2") SECTION("access outside bounds") { - CHECK_THROWS_AS(j.at("foo"), json::out_of_range); - CHECK_THROWS_AS(j_const.at("foo"), json::out_of_range); + CHECK_THROWS_AS(j.at("foo"), json::out_of_range&); + CHECK_THROWS_AS(j_const.at("foo"), json::out_of_range&); CHECK_THROWS_WITH(j.at("foo"), "[json.exception.out_of_range.403] key 'foo' not found"); CHECK_THROWS_WITH(j_const.at("foo"), @@ -77,8 +77,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::null); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with null"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with null"); } @@ -87,8 +87,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::boolean); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with boolean"); } @@ -97,8 +97,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::string); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with string"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with string"); } @@ -107,8 +107,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::array); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with array"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with array"); } @@ -117,8 +117,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_integer); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); } @@ -127,8 +127,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_unsigned); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); } @@ -137,8 +137,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_float); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.at("foo"), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.at("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); CHECK_THROWS_WITH(j_nonobject_const.at("foo"), "[json.exception.type_error.304] cannot use at() with number"); } @@ -202,8 +202,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::null); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with null"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -214,8 +214,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::boolean); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with boolean"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -226,8 +226,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::string); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with string"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -238,8 +238,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::array); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with array"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -250,8 +250,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_integer); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -262,8 +262,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_unsigned); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -274,8 +274,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_float); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("foo", 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("foo", 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("foo", 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("foo", 1), @@ -320,8 +320,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::null); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with null"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -332,8 +332,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::boolean); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with boolean"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -344,8 +344,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::string); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with string"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -356,8 +356,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::array); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with array"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -368,8 +368,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_integer); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -380,8 +380,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_unsigned); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -392,8 +392,8 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_float); const json j_nonobject_const(j_nonobject); - CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error); - CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error); + CHECK_THROWS_AS(j_nonobject.value("/foo"_json_pointer, 1), json::type_error&); + CHECK_THROWS_AS(j_nonobject_const.value("/foo"_json_pointer, 1), json::type_error&); CHECK_THROWS_WITH(j_nonobject.value("/foo"_json_pointer, 1), "[json.exception.type_error.306] cannot use value() with number"); CHECK_THROWS_WITH(j_nonobject_const.value("/foo"_json_pointer, 1), @@ -472,8 +472,8 @@ TEST_CASE("element access 2") const json j_const_nonobject(j_nonobject); CHECK_NOTHROW(j_nonobject["foo"]); 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_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[json::object_t::key_type("foo")], "[json.exception.type_error.305] cannot use operator[] with null"); @@ -483,10 +483,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::boolean); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], @@ -501,10 +501,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::string); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], @@ -519,10 +519,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::array); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); @@ -536,10 +536,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_integer); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], @@ -554,10 +554,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_unsigned); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], @@ -572,10 +572,10 @@ TEST_CASE("element access 2") { json j_nonobject(json::value_t::number_float); const json j_const_nonobject(j_nonobject); - CHECK_THROWS_AS(j_nonobject["foo"], json::type_error); - CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error); - 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_AS(j_nonobject["foo"], json::type_error&); + CHECK_THROWS_AS(j_nonobject[json::object_t::key_type("foo")], json::type_error&); + 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"); CHECK_THROWS_WITH(j_nonobject[json::object_t::key_type("foo")], @@ -722,10 +722,10 @@ TEST_CASE("element access 2") { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_AS(jobject.erase(jobject2.begin()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject.begin(), jobject2.end()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject.end()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject2.end()), json::invalid_iterator); + CHECK_THROWS_AS(jobject.erase(jobject2.begin()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject.begin(), jobject2.end()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject.end()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject2.end()), json::invalid_iterator&); CHECK_THROWS_WITH(jobject.erase(jobject2.begin()), "[json.exception.invalid_iterator.202] iterator does not fit current value"); CHECK_THROWS_WITH(jobject.erase(jobject.begin(), jobject2.end()), @@ -738,10 +738,10 @@ TEST_CASE("element access 2") { json jobject = {{"a", "a"}, {"b", 1}, {"c", 17u}, {"d", false}, {"e", true}}; json jobject2 = {{"a", "a"}, {"b", 1}, {"c", 17u}}; - CHECK_THROWS_AS(jobject.erase(jobject2.cbegin()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject.cbegin(), jobject2.cend()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject.cend()), json::invalid_iterator); - CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject2.cend()), json::invalid_iterator); + CHECK_THROWS_AS(jobject.erase(jobject2.cbegin()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject.cbegin(), jobject2.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject.cend()), json::invalid_iterator&); + CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject2.cend()), json::invalid_iterator&); CHECK_THROWS_WITH(jobject.erase(jobject2.cbegin()), "[json.exception.invalid_iterator.202] iterator does not fit current value"); CHECK_THROWS_WITH(jobject.erase(jobject.cbegin(), jobject2.cend()), @@ -759,7 +759,7 @@ TEST_CASE("element access 2") SECTION("null") { json j_nonobject(json::value_t::null); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with null"); } @@ -767,7 +767,7 @@ TEST_CASE("element access 2") SECTION("boolean") { json j_nonobject(json::value_t::boolean); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with boolean"); } @@ -775,7 +775,7 @@ TEST_CASE("element access 2") SECTION("string") { json j_nonobject(json::value_t::string); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with string"); } @@ -783,7 +783,7 @@ TEST_CASE("element access 2") SECTION("array") { json j_nonobject(json::value_t::array); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with array"); } @@ -791,7 +791,7 @@ TEST_CASE("element access 2") SECTION("number (integer)") { json j_nonobject(json::value_t::number_integer); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with number"); } @@ -799,7 +799,7 @@ TEST_CASE("element access 2") SECTION("number (floating-point)") { json j_nonobject(json::value_t::number_float); - CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error); + CHECK_THROWS_AS(j_nonobject.erase("foo"), json::type_error&); CHECK_THROWS_WITH(j_nonobject.erase("foo"), "[json.exception.type_error.307] cannot use erase() with number"); } diff --git a/test/src/unit-iterators1.cpp b/test/src/unit-iterators1.cpp index 783bf850..78607bc2 100644 --- a/test/src/unit-iterators1.cpp +++ b/test/src/unit-iterators1.cpp @@ -229,19 +229,19 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json(true)); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json(true)); auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -433,19 +433,19 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json("hello world")); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json("hello world")); auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -630,10 +630,10 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json(1)); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json(1)); } @@ -1007,19 +1007,19 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json(23)); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json(23)); auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -1211,19 +1211,19 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json(23)); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json(23)); auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -1415,19 +1415,19 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(it.value() == json(23.42)); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK(cit.value() == json(23.42)); auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -1489,10 +1489,10 @@ TEST_CASE("iterators 1") { auto it = j.begin(); auto cit = j_const.cbegin(); - CHECK_THROWS_AS(it.key(), json::invalid_iterator); - CHECK_THROWS_AS(it.value(), json::invalid_iterator); - CHECK_THROWS_AS(cit.key(), json::invalid_iterator); - CHECK_THROWS_AS(cit.value(), json::invalid_iterator); + CHECK_THROWS_AS(it.key(), json::invalid_iterator&); + CHECK_THROWS_AS(it.value(), json::invalid_iterator&); + CHECK_THROWS_AS(cit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(cit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(it.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); @@ -1500,10 +1500,10 @@ TEST_CASE("iterators 1") auto rit = j.rend(); auto crit = j.crend(); - CHECK_THROWS_AS(rit.key(), json::invalid_iterator); - CHECK_THROWS_AS(rit.value(), json::invalid_iterator); - CHECK_THROWS_AS(crit.key(), json::invalid_iterator); - CHECK_THROWS_AS(crit.value(), json::invalid_iterator); + CHECK_THROWS_AS(rit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(rit.value(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.key(), json::invalid_iterator&); + CHECK_THROWS_AS(crit.value(), json::invalid_iterator&); CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); CHECK_THROWS_WITH(rit.value(), "[json.exception.invalid_iterator.214] cannot get value"); CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators"); diff --git a/test/src/unit-iterators2.cpp b/test/src/unit-iterators2.cpp index 29d134da..be4e2770 100644 --- a/test/src/unit-iterators2.cpp +++ b/test/src/unit-iterators2.cpp @@ -81,14 +81,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 < it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 < it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 < it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 < it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c < it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 < it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 < it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 < it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 < it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c < it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 < it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 < it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -115,14 +115,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 <= it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 <= it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 <= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 <= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c <= it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 <= it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 <= it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 <= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 <= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c <= it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 <= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 <= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -150,14 +150,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 > it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 > it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 > it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 > it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c > it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 > it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 > it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 > it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 > it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c > it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 > it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 > it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -185,14 +185,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 >= it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 >= it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 >= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 >= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c >= it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 >= it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 >= it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 >= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 >= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c >= it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 >= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 >= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -224,13 +224,13 @@ TEST_CASE("iterators 2") { if (j != k) { - CHECK_THROWS_AS(j.begin() == k.begin(), json::invalid_iterator); - CHECK_THROWS_AS(j.cbegin() == k.cbegin(), json::invalid_iterator); + CHECK_THROWS_AS(j.begin() == k.begin(), json::invalid_iterator&); + CHECK_THROWS_AS(j.cbegin() == k.cbegin(), json::invalid_iterator&); CHECK_THROWS_WITH(j.begin() == k.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); CHECK_THROWS_WITH(j.cbegin() == k.cbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); - CHECK_THROWS_AS(j.begin() < k.begin(), json::invalid_iterator); - CHECK_THROWS_AS(j.cbegin() < k.cbegin(), json::invalid_iterator); + CHECK_THROWS_AS(j.begin() < k.begin(), json::invalid_iterator&); + CHECK_THROWS_AS(j.cbegin() < k.cbegin(), json::invalid_iterator&); CHECK_THROWS_WITH(j.begin() < k.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); CHECK_THROWS_WITH(j.cbegin() < k.cbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); } @@ -251,62 +251,62 @@ TEST_CASE("iterators 2") { { auto it = j_object.begin(); - CHECK_THROWS_AS(it += 1, json::invalid_iterator); + CHECK_THROWS_AS(it += 1, json::invalid_iterator&); CHECK_THROWS_WITH(it += 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it += 1, json::invalid_iterator); + CHECK_THROWS_AS(it += 1, json::invalid_iterator&); CHECK_THROWS_WITH(it += 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.begin(); - CHECK_THROWS_AS(it + 1, json::invalid_iterator); + CHECK_THROWS_AS(it + 1, json::invalid_iterator&); CHECK_THROWS_WITH(it + 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it + 1, json::invalid_iterator); + CHECK_THROWS_AS(it + 1, json::invalid_iterator&); CHECK_THROWS_WITH(it + 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.begin(); - CHECK_THROWS_AS(1 + it, json::invalid_iterator); + CHECK_THROWS_AS(1 + it, json::invalid_iterator&); CHECK_THROWS_WITH(1 + it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(1 + it, json::invalid_iterator); + CHECK_THROWS_AS(1 + it, json::invalid_iterator&); CHECK_THROWS_WITH(1 + it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.begin(); - CHECK_THROWS_AS(it -= 1, json::invalid_iterator); + CHECK_THROWS_AS(it -= 1, json::invalid_iterator&); CHECK_THROWS_WITH(it -= 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it -= 1, json::invalid_iterator); + CHECK_THROWS_AS(it -= 1, json::invalid_iterator&); CHECK_THROWS_WITH(it -= 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.begin(); - CHECK_THROWS_AS(it - 1, json::invalid_iterator); + CHECK_THROWS_AS(it - 1, json::invalid_iterator&); CHECK_THROWS_WITH(it - 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it - 1, json::invalid_iterator); + CHECK_THROWS_AS(it - 1, json::invalid_iterator&); CHECK_THROWS_WITH(it - 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.begin(); - CHECK_THROWS_AS(it - it, json::invalid_iterator); + CHECK_THROWS_AS(it - it, json::invalid_iterator&); CHECK_THROWS_WITH(it - it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it - it, json::invalid_iterator); + CHECK_THROWS_AS(it - it, json::invalid_iterator&); CHECK_THROWS_WITH(it - it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } } @@ -396,15 +396,15 @@ TEST_CASE("iterators 2") { { auto it = j_object.begin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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.208] cannot use operator[] for object iterators"); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators"); } { auto it = j_object.cbegin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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.208] cannot use operator[] for object iterators"); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators"); } @@ -436,15 +436,15 @@ TEST_CASE("iterators 2") { { auto it = j_null.begin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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"); } { auto it = j_null.cbegin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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"); } @@ -455,13 +455,13 @@ TEST_CASE("iterators 2") { auto it = j_value.begin(); CHECK(it[0] == json(42)); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + CHECK_THROWS_AS(it[1], json::invalid_iterator&); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } { auto it = j_value.cbegin(); CHECK(it[0] == json(42)); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + CHECK_THROWS_AS(it[1], json::invalid_iterator&); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } } @@ -516,14 +516,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 < it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 < it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 < it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 < it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c < it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c < it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 < it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 < it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 < it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 < it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c < it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c < it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 < it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 < it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 < it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -550,14 +550,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 <= it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 <= it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 <= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 <= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c <= it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c <= it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 <= it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 <= it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 <= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 <= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c <= it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c <= it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 <= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 <= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 <= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -585,14 +585,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 > it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 > it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 > it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 > it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c > it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c > it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 > it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 > it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 > it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 > it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c > it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c > it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 > it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 > it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 > it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -620,14 +620,14 @@ TEST_CASE("iterators 2") { if (j.type() == json::value_t::object) { - CHECK_THROWS_AS(it1 >= it1, json::invalid_iterator); - CHECK_THROWS_AS(it1 >= it2, json::invalid_iterator); - CHECK_THROWS_AS(it2 >= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1 >= it3, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it1_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it2_c, json::invalid_iterator); - CHECK_THROWS_AS(it2_c >= it3_c, json::invalid_iterator); - CHECK_THROWS_AS(it1_c >= it3_c, json::invalid_iterator); + CHECK_THROWS_AS(it1 >= it1, json::invalid_iterator&); + CHECK_THROWS_AS(it1 >= it2, json::invalid_iterator&); + CHECK_THROWS_AS(it2 >= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1 >= it3, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it1_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it2_c, json::invalid_iterator&); + CHECK_THROWS_AS(it2_c >= it3_c, json::invalid_iterator&); + CHECK_THROWS_AS(it1_c >= it3_c, json::invalid_iterator&); CHECK_THROWS_WITH(it1 >= it1, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it1 >= it2, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); CHECK_THROWS_WITH(it2 >= it3, "[json.exception.invalid_iterator.213] cannot compare order of object iterators"); @@ -659,13 +659,13 @@ TEST_CASE("iterators 2") { if (j != k) { - CHECK_THROWS_AS(j.rbegin() == k.rbegin(), json::invalid_iterator); - CHECK_THROWS_AS(j.crbegin() == k.crbegin(), json::invalid_iterator); + CHECK_THROWS_AS(j.rbegin() == k.rbegin(), json::invalid_iterator&); + CHECK_THROWS_AS(j.crbegin() == k.crbegin(), json::invalid_iterator&); CHECK_THROWS_WITH(j.rbegin() == k.rbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); CHECK_THROWS_WITH(j.crbegin() == k.crbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); - CHECK_THROWS_AS(j.rbegin() < k.rbegin(), json::invalid_iterator); - CHECK_THROWS_AS(j.crbegin() < k.crbegin(), json::invalid_iterator); + CHECK_THROWS_AS(j.rbegin() < k.rbegin(), json::invalid_iterator&); + CHECK_THROWS_AS(j.crbegin() < k.crbegin(), json::invalid_iterator&); CHECK_THROWS_WITH(j.rbegin() < k.rbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); CHECK_THROWS_WITH(j.crbegin() < k.crbegin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers"); } @@ -686,62 +686,62 @@ TEST_CASE("iterators 2") { { auto it = j_object.rbegin(); - CHECK_THROWS_AS(it += 1, json::invalid_iterator); + CHECK_THROWS_AS(it += 1, json::invalid_iterator&); 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 += 1, json::invalid_iterator); + CHECK_THROWS_AS(it += 1, json::invalid_iterator&); CHECK_THROWS_WITH(it += 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.rbegin(); - CHECK_THROWS_AS(it + 1, json::invalid_iterator); + CHECK_THROWS_AS(it + 1, json::invalid_iterator&); 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 + 1, json::invalid_iterator); + CHECK_THROWS_AS(it + 1, json::invalid_iterator&); CHECK_THROWS_WITH(it + 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.rbegin(); - CHECK_THROWS_AS(1 + it, json::invalid_iterator); + CHECK_THROWS_AS(1 + it, json::invalid_iterator&); CHECK_THROWS_WITH(1 + it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.crbegin(); - CHECK_THROWS_AS(1 + it, json::invalid_iterator); + CHECK_THROWS_AS(1 + it, json::invalid_iterator&); CHECK_THROWS_WITH(1 + it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.rbegin(); - CHECK_THROWS_AS(it -= 1, json::invalid_iterator); + CHECK_THROWS_AS(it -= 1, json::invalid_iterator&); 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 -= 1, json::invalid_iterator); + CHECK_THROWS_AS(it -= 1, json::invalid_iterator&); CHECK_THROWS_WITH(it -= 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.rbegin(); - CHECK_THROWS_AS(it - 1, json::invalid_iterator); + CHECK_THROWS_AS(it - 1, json::invalid_iterator&); 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 - 1, json::invalid_iterator); + CHECK_THROWS_AS(it - 1, json::invalid_iterator&); CHECK_THROWS_WITH(it - 1, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.rbegin(); - CHECK_THROWS_AS(it - it, json::invalid_iterator); + CHECK_THROWS_AS(it - it, json::invalid_iterator&); CHECK_THROWS_WITH(it - it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } { auto it = j_object.crbegin(); - CHECK_THROWS_AS(it - it, json::invalid_iterator); + CHECK_THROWS_AS(it - it, json::invalid_iterator&); CHECK_THROWS_WITH(it - it, "[json.exception.invalid_iterator.209] cannot use offsets with object iterators"); } } @@ -831,15 +831,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_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"); } { auto it = j_object.crbegin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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"); } @@ -871,15 +871,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_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"); } { auto it = j_null.crbegin(); - CHECK_THROWS_AS(it[0], json::invalid_iterator); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + 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"); } @@ -890,13 +890,13 @@ TEST_CASE("iterators 2") { auto it = j_value.rbegin(); CHECK(it[0] == json(42)); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + CHECK_THROWS_AS(it[1], json::invalid_iterator&); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } { auto it = j_value.crbegin(); CHECK(it[0] == json(42)); - CHECK_THROWS_AS(it[1], json::invalid_iterator); + CHECK_THROWS_AS(it[1], json::invalid_iterator&); CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.214] cannot get value"); } } diff --git a/test/src/unit-json_patch.cpp b/test/src/unit-json_patch.cpp index 9ab86ea4..636fa2bc 100644 --- a/test/src/unit-json_patch.cpp +++ b/test/src/unit-json_patch.cpp @@ -75,7 +75,7 @@ TEST_CASE("JSON patch") json doc2 = R"({ "q": { "bar": 2 } })"_json; // because "a" does not exist. - CHECK_THROWS_AS(doc2.patch(patch), json::out_of_range); + CHECK_THROWS_AS(doc2.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(doc2.patch(patch), "[json.exception.out_of_range.403] key 'a' not found"); } @@ -337,7 +337,7 @@ TEST_CASE("JSON patch") )"_json; // check that evaluation throws - CHECK_THROWS_AS(doc.patch(patch), json::other_error); + CHECK_THROWS_AS(doc.patch(patch), json::other_error&); CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } @@ -421,7 +421,7 @@ TEST_CASE("JSON patch") // references neither the root of the document, nor a member of // an existing object, nor a member of an existing array. - CHECK_THROWS_AS(doc.patch(patch), json::out_of_range); + CHECK_THROWS_AS(doc.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found"); } @@ -478,7 +478,7 @@ TEST_CASE("JSON patch") )"_json; // check that evaluation throws - CHECK_THROWS_AS(doc.patch(patch), json::other_error); + CHECK_THROWS_AS(doc.patch(patch), json::other_error&); CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } @@ -668,7 +668,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{"op", "add"}, {"path", ""}, {"value", 1}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects"); } @@ -677,7 +677,7 @@ TEST_CASE("JSON patch") { json j; json patch = {"op", "add", "path", "", "value", 1}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects"); } @@ -686,7 +686,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"foo", "bar"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have member 'op'"); } @@ -695,7 +695,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have string member 'op'"); } @@ -704,7 +704,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "foo"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation value 'foo' is invalid"); } @@ -716,7 +716,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "add"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'"); } @@ -725,7 +725,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "add"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'"); } @@ -734,7 +734,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "add"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'"); } @@ -743,7 +743,7 @@ TEST_CASE("JSON patch") { json j = {1, 2}; json patch = {{{"op", "add"}, {"path", "/4"}, {"value", 4}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.401] array index 4 is out of range"); } @@ -755,7 +755,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "remove"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'"); } @@ -764,7 +764,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "remove"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'"); } @@ -773,7 +773,7 @@ TEST_CASE("JSON patch") { json j = {1, 2, 3}; json patch = {{{"op", "remove"}, {"path", "/17"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.401] array index 17 is out of range"); } @@ -782,7 +782,7 @@ TEST_CASE("JSON patch") { json j = {{"foo", 1}, {"bar", 2}}; json patch = {{{"op", "remove"}, {"path", "/baz"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found"); } @@ -791,7 +791,7 @@ TEST_CASE("JSON patch") { json j = "string"; json patch = {{{"op", "remove"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.405] JSON pointer has no parent"); } @@ -803,7 +803,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "replace"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'"); } @@ -812,7 +812,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "replace"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'"); } @@ -821,7 +821,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "replace"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'"); } @@ -830,7 +830,7 @@ TEST_CASE("JSON patch") { json j = {1, 2, 3}; json patch = {{{"op", "replace"}, {"path", "/17"}, {"value", 19}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.401] array index 17 is out of range"); } @@ -839,7 +839,7 @@ TEST_CASE("JSON patch") { json j = {{"foo", 1}, {"bar", 2}}; json patch = {{{"op", "replace"}, {"path", "/baz"}, {"value", 3}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found"); } @@ -851,7 +851,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "move"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'"); } @@ -860,7 +860,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "move"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'"); } @@ -869,7 +869,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "move"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'"); } @@ -878,7 +878,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'"); } @@ -887,7 +887,7 @@ TEST_CASE("JSON patch") { json j = {1, 2, 3}; json patch = {{{"op", "move"}, {"path", "/0"}, {"from", "/5"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.401] array index 5 is out of range"); } @@ -896,7 +896,7 @@ TEST_CASE("JSON patch") { json j = {{"foo", 1}, {"bar", 2}}; json patch = {{{"op", "move"}, {"path", "/baz"}, {"from", "/baz"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found"); } @@ -908,7 +908,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "copy"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'"); } @@ -917,7 +917,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "copy"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'"); } @@ -926,7 +926,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "copy"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'"); } @@ -935,7 +935,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'"); } @@ -944,7 +944,7 @@ TEST_CASE("JSON patch") { json j = {1, 2, 3}; json patch = {{{"op", "copy"}, {"path", "/0"}, {"from", "/5"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.401] array index 5 is out of range"); } @@ -953,7 +953,7 @@ TEST_CASE("JSON patch") { json j = {{"foo", 1}, {"bar", 2}}; json patch = {{{"op", "copy"}, {"path", "/fob"}, {"from", "/baz"}}}; - CHECK_THROWS_AS(j.patch(patch), json::out_of_range); + CHECK_THROWS_AS(j.patch(patch), json::out_of_range&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.out_of_range.403] key 'baz' not found"); } @@ -965,7 +965,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "test"}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'"); } @@ -974,7 +974,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "test"}, {"path", 1}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'"); } @@ -983,7 +983,7 @@ TEST_CASE("JSON patch") { json j; json patch = {{{"op", "test"}, {"path", ""}}}; - CHECK_THROWS_AS(j.patch(patch), json::parse_error); + CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'"); } @@ -1177,7 +1177,7 @@ TEST_CASE("JSON patch") )"_json; // the test will fail - CHECK_THROWS_AS(doc.patch(patch), json::other_error); + CHECK_THROWS_AS(doc.patch(patch), json::other_error&); CHECK_THROWS_WITH(doc.patch(patch), "[json.exception.other_error.501] unsuccessful: " + patch[0].dump()); } } diff --git a/test/src/unit-json_pointer.cpp b/test/src/unit-json_pointer.cpp index d14261a0..a9fbc613 100644 --- a/test/src/unit-json_pointer.cpp +++ b/test/src/unit-json_pointer.cpp @@ -36,23 +36,23 @@ TEST_CASE("JSON pointers") { SECTION("errors") { - CHECK_THROWS_AS(json::json_pointer("foo"), json::parse_error); + CHECK_THROWS_AS(json::json_pointer("foo"), json::parse_error&); CHECK_THROWS_WITH(json::json_pointer("foo"), "[json.exception.parse_error.107] parse error at 1: JSON pointer must be empty or begin with '/' - was: 'foo'"); - CHECK_THROWS_AS(json::json_pointer("/~~"), json::parse_error); + CHECK_THROWS_AS(json::json_pointer("/~~"), json::parse_error&); CHECK_THROWS_WITH(json::json_pointer("/~~"), "[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'"); - CHECK_THROWS_AS(json::json_pointer("/~"), json::parse_error); + CHECK_THROWS_AS(json::json_pointer("/~"), json::parse_error&); CHECK_THROWS_WITH(json::json_pointer("/~"), "[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'"); json::json_pointer p; - CHECK_THROWS_AS(p.top(), json::out_of_range); + CHECK_THROWS_AS(p.top(), json::out_of_range&); CHECK_THROWS_WITH(p.top(), "[json.exception.out_of_range.405] JSON pointer has no parent"); - CHECK_THROWS_AS(p.pop_back(), json::out_of_range); + 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"); } @@ -126,10 +126,10 @@ TEST_CASE("JSON pointers") // unresolved access json j_primitive = 1; - CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range); + CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range&); CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], "[json.exception.out_of_range.404] unresolved reference token 'foo'"); - CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), "[json.exception.out_of_range.404] unresolved reference token 'foo'"); } @@ -189,16 +189,16 @@ TEST_CASE("JSON pointers") CHECK(j[json::json_pointer("/m~0n")] == j["m~n"]); // unescaped access - CHECK_THROWS_AS(j.at(json::json_pointer("/a/b")), json::out_of_range); + CHECK_THROWS_AS(j.at(json::json_pointer("/a/b")), json::out_of_range&); CHECK_THROWS_WITH(j.at(json::json_pointer("/a/b")), "[json.exception.out_of_range.403] key 'a' not found"); // unresolved access const json j_primitive = 1; - CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range); + CHECK_THROWS_AS(j_primitive["/foo"_json_pointer], json::out_of_range&); CHECK_THROWS_WITH(j_primitive["/foo"_json_pointer], "[json.exception.out_of_range.404] unresolved reference token 'foo'"); - CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j_primitive.at("/foo"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j_primitive.at("/foo"_json_pointer), "[json.exception.out_of_range.404] unresolved reference token 'foo'"); } @@ -255,35 +255,35 @@ TEST_CASE("JSON pointers") CHECK(j == json({1, 13, 3, 33, nullptr, 55})); // error with leading 0 - CHECK_THROWS_AS(j["/01"_json_pointer], json::parse_error); + CHECK_THROWS_AS(j["/01"_json_pointer], json::parse_error&); CHECK_THROWS_WITH(j["/01"_json_pointer], "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); - CHECK_THROWS_AS(j_const["/01"_json_pointer], json::parse_error); + CHECK_THROWS_AS(j_const["/01"_json_pointer], json::parse_error&); CHECK_THROWS_WITH(j_const["/01"_json_pointer], "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); - CHECK_THROWS_AS(j.at("/01"_json_pointer), json::parse_error); + CHECK_THROWS_AS(j.at("/01"_json_pointer), json::parse_error&); CHECK_THROWS_WITH(j.at("/01"_json_pointer), "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); - CHECK_THROWS_AS(j_const.at("/01"_json_pointer), json::parse_error); + CHECK_THROWS_AS(j_const.at("/01"_json_pointer), json::parse_error&); CHECK_THROWS_WITH(j_const.at("/01"_json_pointer), "[json.exception.parse_error.106] parse error: array index '01' must not begin with '0'"); // error with incorrect numbers - CHECK_THROWS_AS(j["/one"_json_pointer] = 1, json::parse_error); + 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_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_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_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_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"); @@ -292,15 +292,15 @@ TEST_CASE("JSON pointers") CHECK(j == json({1, 13, 3, 33, nullptr, 55, 99})); // error when using "-" in const object - CHECK_THROWS_AS(j_const["/-"_json_pointer], json::out_of_range); + CHECK_THROWS_AS(j_const["/-"_json_pointer], json::out_of_range&); CHECK_THROWS_WITH(j_const["/-"_json_pointer], "[json.exception.out_of_range.402] array index '-' (3) is out of range"); // error when using "-" with at - CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (7) is out of range"); - CHECK_THROWS_AS(j_const.at("/-"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j_const.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j_const.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range"); } @@ -315,20 +315,20 @@ TEST_CASE("JSON pointers") CHECK(j["/2"_json_pointer] == j[2]); // assign to nonexisting index - CHECK_THROWS_AS(j.at("/3"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j.at("/3"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/3"_json_pointer), "[json.exception.out_of_range.401] array index 3 is out of range"); // assign to nonexisting index (with gap) - CHECK_THROWS_AS(j.at("/5"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j.at("/5"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/5"_json_pointer), "[json.exception.out_of_range.401] array index 5 is out of range"); // assign to "-" - CHECK_THROWS_AS(j["/-"_json_pointer], json::out_of_range); + CHECK_THROWS_AS(j["/-"_json_pointer], json::out_of_range&); CHECK_THROWS_WITH(j["/-"_json_pointer], "[json.exception.out_of_range.402] array index '-' (3) is out of range"); - CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range); + CHECK_THROWS_AS(j.at("/-"_json_pointer), json::out_of_range&); CHECK_THROWS_WITH(j.at("/-"_json_pointer), "[json.exception.out_of_range.402] array index '-' (3) is out of range"); } @@ -386,18 +386,18 @@ TEST_CASE("JSON pointers") CHECK(j_flatten.unflatten() == j); // error for nonobjects - CHECK_THROWS_AS(json(1).unflatten(), json::type_error); + CHECK_THROWS_AS(json(1).unflatten(), json::type_error&); CHECK_THROWS_WITH(json(1).unflatten(), "[json.exception.type_error.314] only objects can be unflattened"); // error for nonprimitve values - CHECK_THROWS_AS(json({{"/1", {1, 2, 3}}}).unflatten(), json::type_error); + CHECK_THROWS_AS(json({{"/1", {1, 2, 3}}}).unflatten(), json::type_error&); CHECK_THROWS_WITH(json({{"/1", {1, 2, 3}}}).unflatten(), "[json.exception.type_error.315] values in object must be primitive"); // error for conflicting values json j_error = {{"", 42}, {"/foo", 17}}; - CHECK_THROWS_AS(j_error.unflatten(), json::type_error); + CHECK_THROWS_AS(j_error.unflatten(), json::type_error&); CHECK_THROWS_WITH(j_error.unflatten(), "[json.exception.type_error.313] invalid value to unflatten"); diff --git a/test/src/unit-modifiers.cpp b/test/src/unit-modifiers.cpp index b860beee..eeb70a0c 100644 --- a/test/src/unit-modifiers.cpp +++ b/test/src/unit-modifiers.cpp @@ -152,7 +152,7 @@ TEST_CASE("modifiers") SECTION("other type") { json j = 1; - CHECK_THROWS_AS(j.push_back("Hello"), json::type_error); + CHECK_THROWS_AS(j.push_back("Hello"), json::type_error&); CHECK_THROWS_WITH(j.push_back("Hello"), "[json.exception.type_error.308] cannot use push_back() with number"); } } @@ -182,7 +182,7 @@ TEST_CASE("modifiers") { json j = 1; json k("Hello"); - CHECK_THROWS_AS(j.push_back(k), json::type_error); + CHECK_THROWS_AS(j.push_back(k), json::type_error&); CHECK_THROWS_WITH(j.push_back(k), "[json.exception.type_error.308] cannot use push_back() with number"); } } @@ -215,7 +215,7 @@ TEST_CASE("modifiers") { json j = 1; json k("Hello"); - CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), json::type_error); + CHECK_THROWS_AS(j.push_back(json::object_t::value_type({"one", 1})), json::type_error&); CHECK_THROWS_WITH(j.push_back(json::object_t::value_type({"one", 1})), "[json.exception.type_error.308] cannot use push_back() with number"); } @@ -252,7 +252,7 @@ TEST_CASE("modifiers") CHECK(j == json({{"key1", 1}, {"key2", "bar"}})); json k = {{"key1", 1}}; - CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error); + CHECK_THROWS_AS(k.push_back({1, 2, 3, 4}), json::type_error&); CHECK_THROWS_WITH(k.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object"); } } @@ -291,7 +291,7 @@ TEST_CASE("modifiers") SECTION("other type") { json j = 1; - CHECK_THROWS_AS(j.emplace_back("Hello"), json::type_error); + CHECK_THROWS_AS(j.emplace_back("Hello"), json::type_error&); CHECK_THROWS_WITH(j.emplace_back("Hello"), "[json.exception.type_error.311] cannot use emplace_back() with number"); } @@ -351,7 +351,7 @@ TEST_CASE("modifiers") SECTION("other type") { json j = 1; - CHECK_THROWS_AS(j.emplace("foo", "bar"), json::type_error); + CHECK_THROWS_AS(j.emplace("foo", "bar"), json::type_error&); CHECK_THROWS_WITH(j.emplace("foo", "bar"), "[json.exception.type_error.311] cannot use emplace() with number"); } @@ -383,7 +383,7 @@ TEST_CASE("modifiers") SECTION("other type") { json j = 1; - CHECK_THROWS_AS(j += "Hello", json::type_error); + CHECK_THROWS_AS(j += "Hello", json::type_error&); CHECK_THROWS_WITH(j += "Hello", "[json.exception.type_error.308] cannot use push_back() with number"); } } @@ -413,7 +413,7 @@ TEST_CASE("modifiers") { json j = 1; json k("Hello"); - CHECK_THROWS_AS(j += k, json::type_error); + CHECK_THROWS_AS(j += k, json::type_error&); CHECK_THROWS_WITH(j += k, "[json.exception.type_error.308] cannot use push_back() with number"); } } @@ -446,7 +446,7 @@ TEST_CASE("modifiers") { json j = 1; json k("Hello"); - CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), json::type_error); + CHECK_THROWS_AS(j += json::object_t::value_type({"one", 1}), json::type_error&); CHECK_THROWS_WITH(j += json::object_t::value_type({"one", 1}), "[json.exception.type_error.308] cannot use push_back() with number"); } @@ -483,7 +483,7 @@ TEST_CASE("modifiers") CHECK(j == json({{"key1", 1}, {"key2", "bar"}})); json k = {{"key1", 1}}; - CHECK_THROWS_AS((k += {1, 2, 3, 4}), json::type_error); + CHECK_THROWS_AS((k += {1, 2, 3, 4}), json::type_error&); CHECK_THROWS_WITH((k += {1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object"); } } @@ -620,9 +620,9 @@ TEST_CASE("modifiers") json j_other_array2 = {"first", "second"}; CHECK_THROWS_AS(j_array.insert(j_array.end(), j_array.begin(), j_array.end()), - json::invalid_iterator); + json::invalid_iterator&); CHECK_THROWS_AS(j_array.insert(j_array.end(), j_other_array.begin(), j_other_array2.end()), - json::invalid_iterator); + json::invalid_iterator&); CHECK_THROWS_WITH(j_array.insert(j_array.end(), j_array.begin(), j_array.end()), "[json.exception.invalid_iterator.211] passed iterators may not belong to container"); @@ -652,9 +652,9 @@ TEST_CASE("modifiers") { json j_other_array2 = {"first", "second"}; - CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error); - CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator); - CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator); + CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error&); + CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator&); CHECK_THROWS_WITH(j_array.insert(j_object2.begin(), j_object2.end()), "[json.exception.type_error.309] cannot use insert() with array"); @@ -700,11 +700,11 @@ TEST_CASE("modifiers") // pass iterator to a different array json j_another_array = {1, 2}; json j_yet_another_array = {"first", "second"}; - CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), json::invalid_iterator); - CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), json::invalid_iterator); - CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), json::invalid_iterator); - CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), json::invalid_iterator); - CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), json::invalid_iterator); + CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), json::invalid_iterator&); + CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), json::invalid_iterator&); + CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), json::invalid_iterator&); + CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), json::invalid_iterator&); + CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), json::invalid_iterator&); CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), 10), "[json.exception.invalid_iterator.202] iterator does not fit current value"); @@ -723,12 +723,12 @@ TEST_CASE("modifiers") // call insert on a non-array type json j_nonarray = 3; json j_yet_another_array = {"first", "second"}; - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), json::type_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), json::type_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), json::type_error); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10), json::type_error&); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_value), json::type_error&); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), 10, 11), json::type_error&); CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), j_yet_another_array.begin(), - j_yet_another_array.end()), json::type_error); - CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), json::type_error); + j_yet_another_array.end()), json::type_error&); + CHECK_THROWS_AS(j_nonarray.insert(j_nonarray.end(), {1, 2, 3, 4}), json::type_error&); CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), 10), "[json.exception.type_error.309] cannot use insert() with number"); CHECK_THROWS_WITH(j_nonarray.insert(j_nonarray.end(), j_value), "[json.exception.type_error.309] cannot use insert() with number"); @@ -788,7 +788,7 @@ TEST_CASE("modifiers") json j = 17; json::array_t a = {"foo", "bar", "baz"}; - CHECK_THROWS_AS(j.swap(a), json::type_error); + CHECK_THROWS_AS(j.swap(a), json::type_error&); CHECK_THROWS_WITH(j.swap(a), "[json.exception.type_error.310] cannot use swap() with number"); } } @@ -814,7 +814,7 @@ TEST_CASE("modifiers") json j = 17; json::object_t o = {{"cow", "Kuh"}, {"chicken", "Huhn"}}; - CHECK_THROWS_AS(j.swap(o), json::type_error); + CHECK_THROWS_AS(j.swap(o), json::type_error&); CHECK_THROWS_WITH(j.swap(o), "[json.exception.type_error.310] cannot use swap() with number"); } } @@ -840,7 +840,7 @@ TEST_CASE("modifiers") json j = 17; json::string_t s = "Hallo Welt"; - CHECK_THROWS_AS(j.swap(s), json::type_error); + CHECK_THROWS_AS(j.swap(s), json::type_error&); CHECK_THROWS_WITH(j.swap(s), "[json.exception.type_error.310] cannot use swap() with number"); } } diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 5b1c301d..baef3e35 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -1016,21 +1016,21 @@ TEST_CASE("MessagePack") { SECTION("too short byte vector") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcc})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcc})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcd, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xce, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xcc})), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); @@ -1068,10 +1068,10 @@ TEST_CASE("MessagePack") { SECTION("concrete examples") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc1})), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc1})), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xc1})), "[json.exception.parse_error.112] parse error at 1: error reading MessagePack; last byte: 0xc1"); - CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc6})), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0xc6})), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(std::vector({0xc6})), "[json.exception.parse_error.112] parse error at 1: error reading MessagePack; last byte: 0xc6"); } @@ -1090,14 +1090,14 @@ TEST_CASE("MessagePack") 0xd4, 0xd5, 0xd6, 0xd7, 0xd8 }) { - CHECK_THROWS_AS(json::from_msgpack(std::vector({static_cast(byte)})), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(std::vector({static_cast(byte)})), json::parse_error&); } } } SECTION("invalid string in map") { - CHECK_THROWS_AS(json::from_msgpack(std::vector({0x81, 0xff, 0x01})), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(std::vector({0x81, 0xff, 0x01})), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(std::vector({0x81, 0xff, 0x01})), "[json.exception.parse_error.113] parse error at 2: expected a MessagePack string; last byte: 0xff"); } diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index d4017c7a..e91163c7 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -572,7 +572,7 @@ TEST_CASE("regression tests") SECTION("issue #329 - serialized value not always can be parsed") { - CHECK_THROWS_AS(json::parse("22e2222"), json::out_of_range); + CHECK_THROWS_AS(json::parse("22e2222"), json::out_of_range&); CHECK_THROWS_WITH(json::parse("22e2222"), "[json.exception.out_of_range.406] number overflow parsing '22e2222'"); } @@ -580,7 +580,7 @@ TEST_CASE("regression tests") SECTION("issue #366 - json::parse on failed stream gets stuck") { std::ifstream f("file_not_found.json"); - CHECK_THROWS_AS(json::parse(f), json::parse_error); + CHECK_THROWS_AS(json::parse(f), json::parse_error&); CHECK_THROWS_WITH(json::parse(f), "[json.exception.parse_error.111] parse error: bad input stream"); } @@ -595,7 +595,7 @@ TEST_CASE("regression tests") // ss is not at EOF; this yielded an error before the fix // (threw basic_string::append). No, it should just throw // a parse error because of the EOF. - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -606,7 +606,7 @@ TEST_CASE("regression tests") { std::stringstream ss; json j; - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -616,7 +616,7 @@ TEST_CASE("regression tests") std::stringstream ss; ss << " "; json j; - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -629,7 +629,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == 111); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -642,7 +642,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == 222); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -655,7 +655,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == 333); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -672,7 +672,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == 333); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -691,7 +691,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == ""); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -706,7 +706,7 @@ TEST_CASE("regression tests") CHECK_NOTHROW(ss >> j); CHECK(j == json({{"three", 3}})); - CHECK_THROWS_AS(ss >> j, json::parse_error); + CHECK_THROWS_AS(ss >> j, json::parse_error&); CHECK_THROWS_WITH(ss >> j, "[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"); } @@ -776,7 +776,7 @@ TEST_CASE("regression tests") { // original test case std::vector vec {0x65, 0xf5, 0x0a, 0x48, 0x21}; - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec), "[json.exception.parse_error.110] parse error at 6: unexpected end of input"); } @@ -785,31 +785,31 @@ TEST_CASE("regression tests") { // original test case: incomplete float64 std::vector vec1 {0xcb, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); // related test case: incomplete float32 std::vector vec2 {0xca, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); // related test case: incomplete Half-Precision Float (CBOR) std::vector vec3 {0xf9, 0x8f}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); // related test case: incomplete Single-Precision Float (CBOR) std::vector vec4 {0xfa, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_cbor(vec4), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec4), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec4), "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); // related test case: incomplete Double-Precision Float (CBOR) std::vector vec5 {0xfb, 0x8f, 0x0a}; - CHECK_THROWS_AS(json::from_cbor(vec5), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec5), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec5), "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); } @@ -818,7 +818,7 @@ TEST_CASE("regression tests") { // original test case std::vector vec1 {0x87}; - CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(vec1), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(vec1), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); @@ -832,7 +832,7 @@ TEST_CASE("regression tests") }) { std::vector vec(1, static_cast(b)); - CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error&); } // more test cases for CBOR @@ -847,15 +847,15 @@ TEST_CASE("regression tests") }) { std::vector vec(1, static_cast(b)); - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); } // special case: empty input std::vector vec2; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at 1: unexpected end of input"); - CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_msgpack(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_msgpack(vec2), "[json.exception.parse_error.110] parse error at 1: unexpected end of input"); } @@ -864,19 +864,19 @@ TEST_CASE("regression tests") { // original test case: empty UTF-8 string (indefinite length) std::vector vec1 {0x7f}; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); // related test case: empty array (indefinite length) std::vector vec2 {0x9f}; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); // related test case: empty map (indefinite length) std::vector vec3 {0xbf}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at 2: unexpected end of input"); } @@ -904,25 +904,25 @@ TEST_CASE("regression tests") 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; - CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec), "[json.exception.parse_error.113] parse error at 2: expected a CBOR string; last byte: 0x98"); // related test case: nonempty UTF-8 string (indefinite length) std::vector vec1 {0x7f, 0x61, 0x61}; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec1), "[json.exception.parse_error.110] parse error at 4: unexpected end of input"); // related test case: nonempty array (indefinite length) std::vector vec2 {0x9f, 0x01}; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec2), "[json.exception.parse_error.110] parse error at 3: unexpected end of input"); // related test case: nonempty map (indefinite length) std::vector vec3 {0xbf, 0x61, 0x61, 0x01}; - CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec3), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec3), "[json.exception.parse_error.110] parse error at 5: unexpected end of input"); } @@ -957,7 +957,7 @@ TEST_CASE("regression tests") 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfa }; - CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec1), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec1), "[json.exception.parse_error.113] parse error at 13: expected a CBOR string; last byte: 0xb4"); @@ -971,7 +971,7 @@ TEST_CASE("regression tests") 0x96, 0x96, 0xb4, 0xb4, 0xfa, 0x94, 0x94, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0xfb }; - CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error); + CHECK_THROWS_AS(json::from_cbor(vec2), json::parse_error&); CHECK_THROWS_WITH(json::from_cbor(vec2), "[json.exception.parse_error.113] parse error at 13: expected a CBOR string; last byte: 0xb4"); } @@ -979,7 +979,7 @@ TEST_CASE("regression tests") SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)") { std::vector vec = {'-', '0', '1', '2', '2', '7', '4'}; - CHECK_THROWS_AS(json::parse(vec), json::parse_error); + CHECK_THROWS_AS(json::parse(vec), json::parse_error&); } SECTION("issue #454 - doubles are printed as integers") @@ -1019,9 +1019,9 @@ TEST_CASE("regression tests") }; CHECK_NOTHROW(create(j_array)); - CHECK_THROWS_AS(create(j_number), json::type_error); + CHECK_THROWS_AS(create(j_number), json::type_error&); CHECK_THROWS_WITH(create(j_number), "[json.exception.type_error.302] type must be array, but is number"); - CHECK_THROWS_AS(create(j_null), json::type_error); + CHECK_THROWS_AS(create(j_null), json::type_error&); CHECK_THROWS_WITH(create(j_null), "[json.exception.type_error.302] type must be array, but is null"); } @@ -1033,9 +1033,9 @@ TEST_CASE("regression tests") }; CHECK_NOTHROW(create(j_array)); - CHECK_THROWS_AS(create(j_number), json::type_error); + CHECK_THROWS_AS(create(j_number), json::type_error&); CHECK_THROWS_WITH(create(j_number), "[json.exception.type_error.302] type must be array, but is number"); - CHECK_THROWS_AS(create(j_null), json::type_error); + CHECK_THROWS_AS(create(j_null), json::type_error&); CHECK_THROWS_WITH(create(j_null), "[json.exception.type_error.302] type must be array, but is null"); } @@ -1047,9 +1047,9 @@ TEST_CASE("regression tests") }; CHECK_NOTHROW(create(j_array)); - CHECK_THROWS_AS(create(j_number), json::type_error); + CHECK_THROWS_AS(create(j_number), json::type_error&); CHECK_THROWS_WITH(create(j_number), "[json.exception.type_error.302] type must be array, but is number"); - CHECK_THROWS_AS(create(j_null), json::type_error); + CHECK_THROWS_AS(create(j_null), json::type_error&); CHECK_THROWS_WITH(create(j_null), "[json.exception.type_error.302] type must be array, but is null"); } } @@ -1084,7 +1084,7 @@ TEST_CASE("regression tests") l.m_stream->setstate(std::ios_base::failbit); - CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error); + CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error&); CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream"); } @@ -1099,7 +1099,7 @@ TEST_CASE("regression tests") l.m_stream->setstate(std::ios_base::badbit); - CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error); + CHECK_THROWS_AS(l.fill_line_buffer(), json::parse_error&); CHECK_THROWS_WITH(l.fill_line_buffer(), "[json.exception.parse_error.111] parse error: bad input stream"); } } @@ -1163,7 +1163,7 @@ TEST_CASE("regression tests") SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)") { std::vector vec = {'"', '\\', '"', 'X', '"', '"'}; - CHECK_THROWS_AS(json::parse(vec), json::parse_error); + CHECK_THROWS_AS(json::parse(vec), json::parse_error&); } SECTION("issue #600 - how does one convert a map in Json back to std::map?") diff --git a/test/src/unit-testsuites.cpp b/test/src/unit-testsuites.cpp index d3dbaf4b..d281c679 100644 --- a/test/src/unit-testsuites.cpp +++ b/test/src/unit-testsuites.cpp @@ -78,7 +78,7 @@ TEST_CASE("compliance tests from json.org") { CAPTURE(filename); std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::parse_error); + CHECK_THROWS_AS(json::parse(f), json::parse_error&); } } @@ -772,7 +772,7 @@ TEST_CASE("nst's JSONTestSuite") { CAPTURE(filename); std::ifstream f(filename); - CHECK_THROWS_AS(json::parse(f), json::parse_error); + CHECK_THROWS_AS(json::parse(f), json::parse_error&); } } @@ -848,7 +848,7 @@ TEST_CASE("nst's JSONTestSuite") CAPTURE(filename); std::ifstream f(filename); json j; - CHECK_THROWS_AS(f >> j, json::out_of_range); + CHECK_THROWS_AS(f >> j, json::out_of_range&); } } @@ -875,7 +875,7 @@ TEST_CASE("nst's JSONTestSuite") CAPTURE(filename); std::ifstream f(filename); json j; - CHECK_THROWS_AS(f >> j, json::parse_error); + CHECK_THROWS_AS(f >> j, json::parse_error&); } } } diff --git a/test/src/unit-unicode.cpp b/test/src/unit-unicode.cpp index 70be088e..f2172a9d 100644 --- a/test/src/unit-unicode.cpp +++ b/test/src/unit-unicode.cpp @@ -79,7 +79,7 @@ void check_utf8string(bool success_expected, int byte1, int byte2 = -1, int byte } else { - CHECK_THROWS_AS(json::parse(json_string), json::parse_error); + CHECK_THROWS_AS(json::parse(json_string), json::parse_error&); } } @@ -933,7 +933,7 @@ TEST_CASE("Unicode", "[hide]") { std::string json_text = "\"" + codepoint_to_unicode(cp) + "\""; CAPTURE(json_text); - CHECK_THROWS_AS(json::parse(json_text), json::parse_error); + CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } @@ -952,7 +952,7 @@ TEST_CASE("Unicode", "[hide]") std::string json_text = "\"" + codepoint_to_unicode(cp1) + codepoint_to_unicode(cp2) + "\""; CAPTURE(json_text); - CHECK_THROWS_AS(json::parse(json_text), json::parse_error); + CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } } @@ -965,7 +965,7 @@ TEST_CASE("Unicode", "[hide]") { std::string json_text = "\"" + codepoint_to_unicode(cp) + "\""; CAPTURE(json_text); - CHECK_THROWS_AS(json::parse(json_text), json::parse_error); + CHECK_THROWS_AS(json::parse(json_text), json::parse_error&); } } @@ -1036,7 +1036,7 @@ TEST_CASE("Unicode", "[hide]") SECTION("error for incomplete/wrong BOM") { - CHECK_THROWS_AS(json::parse("\xef\xbb"), json::parse_error); - CHECK_THROWS_AS(json::parse("\xef\xbb\xbb"), json::parse_error); + CHECK_THROWS_AS(json::parse("\xef\xbb"), json::parse_error&); + CHECK_THROWS_AS(json::parse("\xef\xbb\xbb"), json::parse_error&); } }