mirror of
https://github.com/nlohmann/json
synced 2024-12-28 03:11:07 +00:00
parent
fb8482db76
commit
9a70c60fa5
@ -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");
|
||||
}
|
||||
|
@ -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<std::string, std::string> 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<std::string> 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;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ SOFTWARE.
|
||||
#include "json.hpp"
|
||||
using nlohmann::json;
|
||||
|
||||
#include <set>
|
||||
#include <fstream>
|
||||
|
||||
TEST_CASE("CBOR")
|
||||
@ -740,13 +739,13 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
SECTION("no byte follows")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9})),
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
}
|
||||
SECTION("only one byte follows")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c})),
|
||||
"[json.exception.parse_error.110] parse error at 3: unexpected end of input");
|
||||
}
|
||||
@ -1227,28 +1226,28 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
SECTION("empty byte vector")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>()), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>()),
|
||||
"[json.exception.parse_error.110] parse error at 1: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("too short byte vector")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x18})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x19})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x19, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x18})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x19})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x19, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1a, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x18})),
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
@ -1286,10 +1285,10 @@ TEST_CASE("CBOR")
|
||||
{
|
||||
SECTION("concrete examples")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1c})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0x1c})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0x1c})),
|
||||
"[json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0x1C");
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf8})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xf8})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xf8})),
|
||||
"[json.exception.parse_error.112] parse error at 1: error reading CBOR; last byte: 0xF8");
|
||||
}
|
||||
@ -1340,14 +1339,14 @@ TEST_CASE("CBOR")
|
||||
0xf8
|
||||
})
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error&);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("invalid string in map")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_cbor(std::vector<uint8_t>({0xa1, 0xff, 0x01})),
|
||||
"[json.exception.parse_error.113] parse error at 2: expected a CBOR string; last byte: 0xFF");
|
||||
}
|
||||
@ -1363,7 +1362,7 @@ TEST_CASE("CBOR")
|
||||
|
||||
SECTION("strict mode")
|
||||
{
|
||||
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 2: expected end of input");
|
||||
}
|
||||
|
@ -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(std::string(it->type_name()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator&);
|
||||
CHECK_THROWS_WITH(std::string(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(std::string(it->type_name()) == "number");
|
||||
it = j.cend();
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator&);
|
||||
CHECK_THROWS_WITH(std::string(it->type_name()), "[json.exception.invalid_iterator.214] cannot get value");
|
||||
}
|
||||
|
||||
|
@ -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(std::string(it->type_name()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator&);
|
||||
CHECK_THROWS_WITH(std::string(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(std::string(it->type_name()) == "number");
|
||||
it = j.end();
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(std::string(it->type_name()), json::invalid_iterator&);
|
||||
CHECK_THROWS_WITH(std::string(it->type_name()), "[json.exception.invalid_iterator.214] cannot get value");
|
||||
}
|
||||
|
||||
|
@ -123,56 +123,56 @@ TEST_CASE("parser class")
|
||||
SECTION("errors")
|
||||
{
|
||||
// error: tab in string
|
||||
CHECK_THROWS_AS(parser_helper("\"\t\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\t\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("\"\t\""),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+0009>'");
|
||||
// error: newline in string
|
||||
CHECK_THROWS_AS(parser_helper("\"\n\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\r\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\n\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\r\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("\"\n\""),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+000A>'");
|
||||
CHECK_THROWS_WITH(parser_helper("\"\r\""),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+000D>'");
|
||||
// error: backspace in string
|
||||
CHECK_THROWS_AS(parser_helper("\"\b\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\b\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("\"\b\""),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+0008>'");
|
||||
// improve code coverage
|
||||
CHECK_THROWS_AS(parser_helper("\uFF01"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("[-4:1,]"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\uFF01"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("[-4:1,]"), json::parse_error&);
|
||||
// unescaped control characters
|
||||
CHECK_THROWS_AS(parser_helper("\"\x00\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x01\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x02\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x03\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x04\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x05\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x06\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x07\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x08\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x09\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0a\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0b\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0c\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0d\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0e\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0f\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x10\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x11\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x12\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x13\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x14\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x15\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x16\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x17\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x18\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x19\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1a\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1b\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1c\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1d\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1e\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1f\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x00\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x01\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x02\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x03\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x04\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x05\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x06\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x07\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x08\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x09\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0a\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0b\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0c\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0d\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0e\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x0f\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x10\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x11\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x12\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x13\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x14\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x15\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x16\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x17\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x18\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x19\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1a\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1b\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1c\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1d\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1e\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\x1f\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("\"\x00\""), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: missing closing quote; last read: '\"'");
|
||||
CHECK_THROWS_WITH(parser_helper("\"\x01\""), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+0001>'");
|
||||
CHECK_THROWS_WITH(parser_helper("\"\x02\""), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+0002>'");
|
||||
@ -214,7 +214,7 @@ TEST_CASE("parser class")
|
||||
// uses an iterator range.
|
||||
std::string s = "\"1\"";
|
||||
s[1] = '\0';
|
||||
CHECK_THROWS_AS(json::parse(s.begin(), s.end()), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(s.begin(), s.end()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(s.begin(), s.end()), "[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: control character must be escaped; last read: '\"<U+0000>'");
|
||||
}
|
||||
}
|
||||
@ -386,33 +386,33 @@ TEST_CASE("parser class")
|
||||
SECTION("overflow")
|
||||
{
|
||||
// overflows during parsing yield an exception
|
||||
CHECK_THROWS_AS(parser_helper("1.18973e+4932") == json(), json::out_of_range);
|
||||
CHECK_THROWS_AS(parser_helper("1.18973e+4932") == json(), json::out_of_range&);
|
||||
CHECK_THROWS_WITH(parser_helper("1.18973e+4932") == json(),
|
||||
"[json.exception.out_of_range.406] number overflow parsing '1.18973e+4932'");
|
||||
}
|
||||
|
||||
SECTION("invalid numbers")
|
||||
{
|
||||
CHECK_THROWS_AS(parser_helper("01"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("--1"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1E"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1E-"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1.E1"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-1E"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0E#"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0E-#"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0#"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0.0:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0.0Z"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0E123:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0e0-:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0e-:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0f"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("01"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("--1"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1E"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1E-"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1.E1"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-1E"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0E#"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0E-#"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0#"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0.0:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0.0Z"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0E123:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0e0-:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0e-:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0f"), json::parse_error&);
|
||||
|
||||
// numbers must not begin with "+"
|
||||
CHECK_THROWS_AS(parser_helper("+1"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("+0"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("+1"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("+0"), json::parse_error&);
|
||||
|
||||
CHECK_THROWS_WITH(parser_helper("01"),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected number literal; expected end of input");
|
||||
@ -717,20 +717,20 @@ TEST_CASE("parser class")
|
||||
SECTION("parse errors")
|
||||
{
|
||||
// unexpected end of number
|
||||
CHECK_THROWS_AS(parser_helper("0."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("--"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-0."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("-:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("0.:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("e."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1e."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1e/"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1e:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1E."), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1E/"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("1E:"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("0."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("--"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-0."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("-:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("0.:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("e."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1e."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1e/"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1e:"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1E."), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1E/"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("1E:"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("0."),
|
||||
"[json.exception.parse_error.101] parse error at 3: syntax error - invalid number; expected digit after '.'; last read: '0.'");
|
||||
CHECK_THROWS_WITH(parser_helper("-"),
|
||||
@ -761,11 +761,11 @@ 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(parser_helper("n"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("nu"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("nul"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("nulk"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("nulm"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("n"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("nu"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("nul"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("nulk"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("nulm"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("n"),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 'n'");
|
||||
CHECK_THROWS_WITH(parser_helper("nu"),
|
||||
@ -778,11 +778,11 @@ TEST_CASE("parser class")
|
||||
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid literal; last read: 'nulm'");
|
||||
|
||||
// unexpected end of true
|
||||
CHECK_THROWS_AS(parser_helper("t"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("tr"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("tru"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("trud"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("truf"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("t"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("tr"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("tru"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("trud"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("truf"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("t"),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 't'");
|
||||
CHECK_THROWS_WITH(parser_helper("tr"),
|
||||
@ -795,12 +795,12 @@ TEST_CASE("parser class")
|
||||
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid literal; last read: 'truf'");
|
||||
|
||||
// unexpected end of false
|
||||
CHECK_THROWS_AS(parser_helper("f"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("fa"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("fal"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("fals"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("falsd"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("falsf"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("f"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("fa"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("fal"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("fals"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("falsd"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("falsf"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("f"),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid literal; last read: 'f'");
|
||||
CHECK_THROWS_WITH(parser_helper("fa"),
|
||||
@ -815,11 +815,11 @@ TEST_CASE("parser class")
|
||||
"[json.exception.parse_error.101] parse error at 5: syntax error - invalid literal; last read: 'falsf'");
|
||||
|
||||
// missing/unexpected end of array
|
||||
CHECK_THROWS_AS(parser_helper("["), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("[1"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("[1,"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("[1,]"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("]"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("["), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("[1"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("[1,"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("[1,]"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("]"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("["),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
CHECK_THROWS_WITH(parser_helper("[1"),
|
||||
@ -832,12 +832,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(parser_helper("{"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":}"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":1,}"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("}"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":}"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("{\"foo\":1,}"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("}"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("{"),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - unexpected end of input; expected string literal");
|
||||
CHECK_THROWS_WITH(parser_helper("{\"foo\""),
|
||||
@ -852,16 +852,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(parser_helper("\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u0\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u01\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u012\""), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u0"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u01"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u012"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u0\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u01\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u012\""), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u0"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u01"), json::parse_error&);
|
||||
CHECK_THROWS_AS(parser_helper("\"\\u012"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("\""),
|
||||
"[json.exception.parse_error.101] parse error at 2: syntax error - invalid string: missing closing quote; last read: '\"'");
|
||||
CHECK_THROWS_WITH(parser_helper("\"\\\""),
|
||||
@ -913,7 +913,7 @@ TEST_CASE("parser class")
|
||||
// any other combination of backslash and character is invalid
|
||||
default:
|
||||
{
|
||||
CHECK_THROWS_AS(parser_helper(s.c_str()), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper(s.c_str()), json::parse_error&);
|
||||
// only check error message if c is not a control character
|
||||
if (c > 0x1f)
|
||||
{
|
||||
@ -989,7 +989,7 @@ TEST_CASE("parser class")
|
||||
else
|
||||
{
|
||||
CAPTURE(s1);
|
||||
CHECK_THROWS_AS(parser_helper(s1.c_str()), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper(s1.c_str()), json::parse_error&);
|
||||
// only check error message if c is not a control character
|
||||
if (c > 0x1f)
|
||||
{
|
||||
@ -998,7 +998,7 @@ TEST_CASE("parser class")
|
||||
}
|
||||
|
||||
CAPTURE(s2);
|
||||
CHECK_THROWS_AS(parser_helper(s2.c_str()), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper(s2.c_str()), json::parse_error&);
|
||||
// only check error message if c is not a control character
|
||||
if (c > 0x1f)
|
||||
{
|
||||
@ -1007,7 +1007,7 @@ TEST_CASE("parser class")
|
||||
}
|
||||
|
||||
CAPTURE(s3);
|
||||
CHECK_THROWS_AS(parser_helper(s3.c_str()), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper(s3.c_str()), json::parse_error&);
|
||||
// only check error message if c is not a control character
|
||||
if (c > 0x1f)
|
||||
{
|
||||
@ -1016,7 +1016,7 @@ TEST_CASE("parser class")
|
||||
}
|
||||
|
||||
CAPTURE(s4);
|
||||
CHECK_THROWS_AS(parser_helper(s4.c_str()), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper(s4.c_str()), json::parse_error&);
|
||||
// only check error message if c is not a control character
|
||||
if (c > 0x1f)
|
||||
{
|
||||
@ -1028,13 +1028,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\""),
|
||||
@ -1229,11 +1229,11 @@ TEST_CASE("parser class")
|
||||
SECTION("tests found by mutate++")
|
||||
{
|
||||
// test case to make sure no comma preceeds the first key
|
||||
CHECK_THROWS_AS(parser_helper("{,\"key\": false}"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("{,\"key\": false}"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("{,\"key\": false}"),
|
||||
"[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(parser_helper("[{\"key\": false true]"), json::parse_error);
|
||||
CHECK_THROWS_AS(parser_helper("[{\"key\": false true]"), json::parse_error&);
|
||||
CHECK_THROWS_WITH(parser_helper("[{\"key\": false true]"),
|
||||
"[json.exception.parse_error.101] parse error at 19: syntax error - unexpected true literal; expected '}'");
|
||||
|
||||
|
@ -36,7 +36,6 @@ using nlohmann::json;
|
||||
#include <forward_list>
|
||||
#include <fstream>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <valarray>
|
||||
@ -1050,7 +1049,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");
|
||||
}
|
||||
@ -1264,16 +1263,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");
|
||||
}
|
||||
@ -1329,16 +1328,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");
|
||||
}
|
||||
@ -1353,13 +1352,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");
|
||||
}
|
||||
@ -1442,15 +1441,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");
|
||||
}
|
||||
@ -1460,15 +1459,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");
|
||||
}
|
||||
@ -1478,15 +1477,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");
|
||||
}
|
||||
@ -1496,15 +1495,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");
|
||||
}
|
||||
@ -1514,15 +1513,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");
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ using nlohmann::json;
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <valarray>
|
||||
@ -80,13 +79,13 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-object type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::object_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::object_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::object_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<json::object_t>(),
|
||||
"[json.exception.type_error.302] type must be object, but is null");
|
||||
@ -163,7 +162,7 @@ TEST_CASE("value conversion")
|
||||
std::forward_list<json> a = j.get<std::forward_list<json>>();
|
||||
CHECK(json(a) == j);
|
||||
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<std::forward_list<json>>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<std::forward_list<json>>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<std::forward_list<json>>(),
|
||||
"[json.exception.type_error.302] type must be array, but is null");
|
||||
}
|
||||
@ -173,7 +172,7 @@ TEST_CASE("value conversion")
|
||||
std::vector<json> a = j.get<std::vector<json>>();
|
||||
CHECK(json(a) == j);
|
||||
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<std::vector<json>>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<std::vector<json>>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<std::vector<json>>(),
|
||||
"[json.exception.type_error.302] type must be array, but is null");
|
||||
|
||||
@ -182,7 +181,7 @@ TEST_CASE("value conversion")
|
||||
{
|
||||
// making the call to from_json throw in order to check capacity
|
||||
std::vector<float> 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
|
||||
@ -214,13 +213,13 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-array type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::array_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::array_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::array_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::object).get<std::vector<int>>(),
|
||||
"[json.exception.type_error.302] type must be array, but is object");
|
||||
@ -296,13 +295,13 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-string type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::string_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::string_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::string_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<json::string_t>(),
|
||||
"[json.exception.type_error.302] type must be string, but is null");
|
||||
@ -358,13 +357,13 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-string type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::boolean_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_integer).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_unsigned).get<json::boolean_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::number_float).get<json::boolean_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<json::boolean_t>(),
|
||||
"[json.exception.type_error.302] type must be boolean, but is null");
|
||||
@ -614,11 +613,11 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-number type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::number_integer_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::number_integer_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::number_integer_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::number_integer_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::number_integer_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::number_integer_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::number_integer_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::number_integer_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::number_integer_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::number_integer_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<json::number_integer_t>(),
|
||||
"[json.exception.type_error.302] type must be number, but is null");
|
||||
@ -873,11 +872,11 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-string type")
|
||||
{
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::number_float_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::number_float_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::number_float_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::number_float_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::number_float_t>(), json::type_error);
|
||||
CHECK_THROWS_AS(json(json::value_t::null).get<json::number_float_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::object).get<json::number_float_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::array).get<json::number_float_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::string).get<json::number_float_t>(), json::type_error&);
|
||||
CHECK_THROWS_AS(json(json::value_t::boolean).get<json::number_float_t>(), json::type_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json(json::value_t::null).get<json::number_float_t>(),
|
||||
"[json.exception.type_error.302] type must be number, but is null");
|
||||
@ -979,7 +978,7 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-object type")
|
||||
{
|
||||
CHECK_THROWS_AS((json().get<std::map<std::string, int>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::map<std::string, int>>()), json::type_error&);
|
||||
CHECK_THROWS_WITH((json().get<std::map<std::string, int>>()), "[json.exception.type_error.302] type must be object, but is null");
|
||||
}
|
||||
}
|
||||
@ -1081,11 +1080,11 @@ TEST_CASE("value conversion")
|
||||
|
||||
SECTION("exception in case of a non-object type")
|
||||
{
|
||||
CHECK_THROWS_AS((json().get<std::list<int>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::vector<int>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::vector<json>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::list<json>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::valarray<int>>()), json::type_error);
|
||||
CHECK_THROWS_AS((json().get<std::list<int>>()), json::type_error&);
|
||||
CHECK_THROWS_AS((json().get<std::vector<int>>()), json::type_error&);
|
||||
CHECK_THROWS_AS((json().get<std::vector<json>>()), json::type_error&);
|
||||
CHECK_THROWS_AS((json().get<std::list<json>>()), json::type_error&);
|
||||
CHECK_THROWS_AS((json().get<std::valarray<int>>()), 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
|
||||
|
@ -97,7 +97,7 @@ TEST_CASE("deserialization")
|
||||
ss2 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
ss3 << "[\"foo\",1,2,3,false,{\"one\":1}";
|
||||
ss4 << "[\"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));
|
||||
@ -110,7 +110,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));
|
||||
@ -126,7 +126,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 ']'");
|
||||
}
|
||||
@ -137,14 +137,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 ']'");
|
||||
}
|
||||
@ -205,7 +205,7 @@ TEST_CASE("deserialization")
|
||||
SECTION("empty container")
|
||||
{
|
||||
std::vector<uint8_t> v;
|
||||
CHECK_THROWS_AS(json::parse(v), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(v), json::parse_error&);
|
||||
CHECK(not json::accept(v));
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ TEST_CASE("deserialization")
|
||||
SECTION("with empty range")
|
||||
{
|
||||
std::vector<uint8_t> 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)));
|
||||
}
|
||||
}
|
||||
@ -268,7 +268,7 @@ 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)));
|
||||
|
||||
json j_error;
|
||||
@ -279,7 +279,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -290,7 +290,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -301,7 +301,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -312,7 +312,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -323,7 +323,7 @@ TEST_CASE("deserialization")
|
||||
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_THROWS_WITH(json::parse(std::begin(v), std::end(v)),
|
||||
"[json.exception.parse_error.101] parse error at 4: syntax error - invalid string: ill-formed UTF-8 byte; last read: '\"\x7f\xdf\x7f'");
|
||||
CHECK(not json::accept(std::begin(v), std::end(v)));
|
||||
@ -336,7 +336,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -347,7 +347,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -358,7 +358,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -369,7 +369,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -380,7 +380,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -391,7 +391,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -402,7 +402,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -413,7 +413,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -424,7 +424,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -435,7 +435,7 @@ TEST_CASE("deserialization")
|
||||
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)));
|
||||
|
||||
json j_error;
|
||||
@ -451,11 +451,11 @@ TEST_CASE("deserialization")
|
||||
|
||||
SECTION("BOM only")
|
||||
{
|
||||
CHECK_THROWS_AS(json::parse(bom), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(bom), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(bom),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom)), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
}
|
||||
@ -468,22 +468,22 @@ TEST_CASE("deserialization")
|
||||
|
||||
SECTION("2 byte of BOM")
|
||||
{
|
||||
CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(bom.substr(0, 2)), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(bom),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 2))), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
}
|
||||
|
||||
SECTION("1 byte of BOM")
|
||||
{
|
||||
CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(bom.substr(0, 1)), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(bom),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(bom.substr(0, 1))), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse(std::istringstream(bom)),
|
||||
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
}
|
||||
@ -517,8 +517,8 @@ TEST_CASE("deserialization")
|
||||
else
|
||||
{
|
||||
// any variation is an error
|
||||
CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse(s + "null"), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::parse(std::istringstream(s + "null")), json::parse_error&);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -337,19 +337,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");
|
||||
@ -541,19 +541,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");
|
||||
@ -738,10 +738,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));
|
||||
}
|
||||
@ -1115,19 +1115,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");
|
||||
@ -1319,19 +1319,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");
|
||||
@ -1523,19 +1523,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");
|
||||
@ -1597,10 +1597,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");
|
||||
@ -1608,10 +1608,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");
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
|
||||
|
@ -172,7 +172,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");
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,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");
|
||||
}
|
||||
}
|
||||
@ -235,7 +235,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");
|
||||
}
|
||||
@ -272,11 +272,11 @@ TEST_CASE("modifiers")
|
||||
CHECK(j == json({{"key1", 1}, {"key2", "bar"}}));
|
||||
|
||||
// invalid values (no string/val pair)
|
||||
CHECK_THROWS_AS(j.push_back({1}), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back({1}), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back({1}), "[json.exception.type_error.308] cannot use push_back() with object");
|
||||
CHECK_THROWS_AS(j.push_back({1, 2}), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back({1, 2}), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back({1, 2}), "[json.exception.type_error.308] cannot use push_back() with object");
|
||||
CHECK_THROWS_AS(j.push_back({1, 2, 3, 4}), json::type_error);
|
||||
CHECK_THROWS_AS(j.push_back({1, 2, 3, 4}), json::type_error&);
|
||||
CHECK_THROWS_WITH(j.push_back({1, 2, 3, 4}), "[json.exception.type_error.308] cannot use push_back() with object");
|
||||
}
|
||||
}
|
||||
@ -315,7 +315,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");
|
||||
}
|
||||
@ -375,7 +375,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");
|
||||
}
|
||||
@ -407,7 +407,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");
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,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");
|
||||
}
|
||||
}
|
||||
@ -470,7 +470,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");
|
||||
}
|
||||
@ -507,7 +507,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");
|
||||
}
|
||||
}
|
||||
@ -644,9 +644,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");
|
||||
@ -676,9 +676,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");
|
||||
@ -724,11 +724,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");
|
||||
@ -747,12 +747,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");
|
||||
@ -784,10 +784,10 @@ TEST_CASE("modifiers")
|
||||
|
||||
SECTION("wrong types")
|
||||
{
|
||||
CHECK_THROWS_AS(j_array.update(j_object1), json::type_error);
|
||||
CHECK_THROWS_AS(j_array.update(j_object1), json::type_error&);
|
||||
CHECK_THROWS_WITH(j_array.update(j_object1), "[json.exception.type_error.312] cannot use update() with array");
|
||||
|
||||
CHECK_THROWS_AS(j_object1.update(j_array), json::type_error);
|
||||
CHECK_THROWS_AS(j_object1.update(j_array), json::type_error&);
|
||||
CHECK_THROWS_WITH(j_object1.update(j_array), "[json.exception.type_error.312] cannot use update() with array");
|
||||
}
|
||||
}
|
||||
@ -814,9 +814,9 @@ TEST_CASE("modifiers")
|
||||
{
|
||||
json j_other_array2 = {"first", "second"};
|
||||
|
||||
CHECK_THROWS_AS(j_array.update(j_object2.begin(), j_object2.end()), json::type_error);
|
||||
CHECK_THROWS_AS(j_object1.update(j_object1.begin(), j_object2.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_object1.update(j_array.begin(), j_array.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_array.update(j_object2.begin(), j_object2.end()), json::type_error&);
|
||||
CHECK_THROWS_AS(j_object1.update(j_object1.begin(), j_object2.end()), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_object1.update(j_array.begin(), j_array.end()), json::invalid_iterator&);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.update(j_object2.begin(), j_object2.end()),
|
||||
"[json.exception.type_error.312] cannot use update() with array");
|
||||
@ -876,7 +876,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");
|
||||
}
|
||||
}
|
||||
@ -902,7 +902,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");
|
||||
}
|
||||
}
|
||||
@ -928,7 +928,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");
|
||||
}
|
||||
}
|
||||
|
@ -1016,28 +1016,28 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
SECTION("empty byte vector")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>()), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>()), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>()),
|
||||
"[json.exception.parse_error.110] parse error at 1: unexpected end of input");
|
||||
}
|
||||
|
||||
SECTION("too short byte vector")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcc})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcd})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcd, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcc})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcd})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcd, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xce, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00})), json::parse_error&);
|
||||
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xcc})),
|
||||
"[json.exception.parse_error.110] parse error at 2: unexpected end of input");
|
||||
@ -1075,10 +1075,10 @@ TEST_CASE("MessagePack")
|
||||
{
|
||||
SECTION("concrete examples")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc1})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc1})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xc1})),
|
||||
"[json.exception.parse_error.112] parse error at 1: error reading MessagePack; last byte: 0xC1");
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc6})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0xc6})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0xc6})),
|
||||
"[json.exception.parse_error.112] parse error at 1: error reading MessagePack; last byte: 0xC6");
|
||||
}
|
||||
@ -1097,14 +1097,14 @@ TEST_CASE("MessagePack")
|
||||
0xd4, 0xd5, 0xd6, 0xd7, 0xd8
|
||||
})
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({static_cast<uint8_t>(byte)})), json::parse_error&);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("invalid string in map")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(std::vector<uint8_t>({0x81, 0xff, 0x01})),
|
||||
"[json.exception.parse_error.113] parse error at 2: expected a MessagePack string; last byte: 0xFF");
|
||||
}
|
||||
@ -1120,7 +1120,7 @@ TEST_CASE("MessagePack")
|
||||
|
||||
SECTION("strict mode")
|
||||
{
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error);
|
||||
CHECK_THROWS_AS(json::from_msgpack(vec), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::from_msgpack(vec),
|
||||
"[json.exception.parse_error.110] parse error at 2: expected end of input");
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ SOFTWARE.
|
||||
#include "json.hpp"
|
||||
using nlohmann::json;
|
||||
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <list>
|
||||
|
@ -64,22 +64,22 @@ TEST_CASE("reference access")
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_NOTHROW(value.get_ref<json::object_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is object");
|
||||
}
|
||||
@ -113,23 +113,23 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
CHECK_NOTHROW(value.get_ref<json::array_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is array");
|
||||
}
|
||||
@ -149,23 +149,23 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
CHECK_NOTHROW(value.get_ref<json::string_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is string");
|
||||
}
|
||||
@ -185,23 +185,23 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
CHECK_NOTHROW(value.get_ref<json::boolean_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is boolean");
|
||||
}
|
||||
@ -221,23 +221,23 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_NOTHROW(value.get_ref<json::number_integer_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
}
|
||||
@ -257,23 +257,23 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
//CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
//CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
//CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
// "[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_NOTHROW(value.get_ref<json::number_unsigned_t&>());
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_float_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_float_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
}
|
||||
@ -293,22 +293,22 @@ TEST_CASE("reference access")
|
||||
CHECK(p2 == value.get<test_type>());
|
||||
|
||||
// check if mismatching references throw correctly
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::object_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::object_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::array_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::array_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::string_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::string_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::boolean_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::boolean_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_integer_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_integer_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error);
|
||||
CHECK_THROWS_AS(value.get_ref<json::number_unsigned_t&>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(value.get_ref<json::number_unsigned_t&>(),
|
||||
"[json.exception.type_error.303] incompatible ReferenceType for get_ref, actual type is number");
|
||||
CHECK_NOTHROW(value.get_ref<json::number_float_t&>());
|
||||
|
@ -588,7 +588,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'");
|
||||
}
|
||||
@ -596,7 +596,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.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal");
|
||||
}
|
||||
|
||||
@ -611,7 +611,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");
|
||||
}
|
||||
@ -622,7 +622,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");
|
||||
}
|
||||
@ -632,7 +632,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");
|
||||
}
|
||||
@ -645,7 +645,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");
|
||||
}
|
||||
@ -658,7 +658,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");
|
||||
}
|
||||
@ -671,7 +671,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");
|
||||
}
|
||||
@ -688,7 +688,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");
|
||||
}
|
||||
@ -707,7 +707,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");
|
||||
}
|
||||
@ -722,7 +722,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");
|
||||
}
|
||||
@ -792,7 +792,7 @@ TEST_CASE("regression tests")
|
||||
{
|
||||
// original test case
|
||||
std::vector<uint8_t> 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");
|
||||
}
|
||||
@ -801,31 +801,31 @@ TEST_CASE("regression tests")
|
||||
{
|
||||
// original test case: incomplete float64
|
||||
std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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");
|
||||
}
|
||||
@ -834,7 +834,7 @@ TEST_CASE("regression tests")
|
||||
{
|
||||
// original test case
|
||||
std::vector<uint8_t> 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");
|
||||
|
||||
@ -848,7 +848,7 @@ TEST_CASE("regression tests")
|
||||
})
|
||||
{
|
||||
std::vector<uint8_t> vec(1, static_cast<uint8_t>(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
|
||||
@ -863,15 +863,15 @@ TEST_CASE("regression tests")
|
||||
})
|
||||
{
|
||||
std::vector<uint8_t> vec(1, static_cast<uint8_t>(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<uint8_t> 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");
|
||||
}
|
||||
@ -880,19 +880,19 @@ TEST_CASE("regression tests")
|
||||
{
|
||||
// original test case: empty UTF-8 string (indefinite length)
|
||||
std::vector<uint8_t> 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<uint8_t> 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<uint8_t> 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");
|
||||
}
|
||||
@ -920,25 +920,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<uint8_t> 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<uint8_t> 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<uint8_t> 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");
|
||||
}
|
||||
@ -973,7 +973,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");
|
||||
|
||||
@ -987,7 +987,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");
|
||||
}
|
||||
@ -995,7 +995,7 @@ TEST_CASE("regression tests")
|
||||
SECTION("issue #452 - Heap-buffer-overflow (OSS-Fuzz issue 585)")
|
||||
{
|
||||
std::vector<uint8_t> 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")
|
||||
@ -1035,9 +1035,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");
|
||||
}
|
||||
|
||||
@ -1049,9 +1049,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");
|
||||
}
|
||||
|
||||
@ -1063,9 +1063,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");
|
||||
}
|
||||
}
|
||||
@ -1100,7 +1100,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");
|
||||
}
|
||||
|
||||
@ -1115,7 +1115,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");
|
||||
}
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ TEST_CASE("regression tests")
|
||||
SECTION("issue #575 - heap-buffer-overflow (OSS-Fuzz 1400)")
|
||||
{
|
||||
std::vector<uint8_t> 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?")
|
||||
@ -1244,7 +1244,7 @@ TEST_CASE("regression tests")
|
||||
CHECK(v[i] == j[i]);
|
||||
}
|
||||
|
||||
CHECK_THROWS_AS(json().get<std::valarray<double>>(), json::type_error);
|
||||
CHECK_THROWS_AS(json().get<std::valarray<double>>(), json::type_error&);
|
||||
CHECK_THROWS_WITH(json().get<std::valarray<double>>(),
|
||||
"[json.exception.type_error.302] type must be array, but is null");
|
||||
}
|
||||
|
@ -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&);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,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&);
|
||||
}
|
||||
}
|
||||
|
||||
@ -928,31 +928,31 @@ TEST_CASE("Unicode", "[hide]")
|
||||
{
|
||||
SECTION("incorrect surrogate values")
|
||||
{
|
||||
CHECK_THROWS_AS(json::parse("\"\\uDC00\\uDC00\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uDC00\\uDC00\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uDC00\\uDC00\""),
|
||||
"[json.exception.parse_error.101] parse error at 7: syntax error - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uDC00'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD7FF\\uDC00\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD7FF\\uDC00\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD7FF\\uDC00\""),
|
||||
"[json.exception.parse_error.101] parse error at 13: syntax error - invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF; last read: '\"\\uD7FF\\uDC00'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800]\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800]\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD800]\""),
|
||||
"[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: '\"\\uD800]'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\v\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\v\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD800\\v\""),
|
||||
"[json.exception.parse_error.101] parse error at 9: syntax error - invalid string: surrogate U+DC00..U+DFFF must be followed by U+DC00..U+DFFF; last read: '\"\\uD800\\v'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\u123\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\u123\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD800\\u123\""),
|
||||
"[json.exception.parse_error.101] parse error at 13: syntax error - invalid string: '\\u' must be followed by 4 hex digits; last read: '\"\\uD800\\u123\"'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\uDBFF\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\uDBFF\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD800\\uDBFF\""),
|
||||
"[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: '\"\\uD800\\uDBFF'");
|
||||
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\uE000\""), json::parse_error);
|
||||
CHECK_THROWS_AS(json::parse("\"\\uD800\\uE000\""), json::parse_error&);
|
||||
CHECK_THROWS_WITH(json::parse("\"\\uD800\\uE000\""),
|
||||
"[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: '\"\\uD800\\uE000'");
|
||||
}
|
||||
@ -969,7 +969,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&);
|
||||
}
|
||||
}
|
||||
|
||||
@ -988,7 +988,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&);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1001,7 +1001,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&);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1072,7 +1072,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&);
|
||||
}
|
||||
}
|
||||
|
17832
test/thirdparty/catch/catch.hpp
vendored
17832
test/thirdparty/catch/catch.hpp
vendored
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user