mirror of
https://github.com/nlohmann/json
synced 2024-11-23 20:40:08 +00:00
🔨 added user-defined exceptions 203-204
This commit is contained in:
parent
9381f6c4da
commit
875b2da95d
14
src/json.hpp
14
src/json.hpp
@ -2418,7 +2418,7 @@ class basic_json
|
||||
@throw invalid_iterator.201 if iterators are not compatible; that is, do
|
||||
not belong to the same JSON value; example: `"iterators are not
|
||||
compatible"`
|
||||
@throw std::out_of_range if iterators are for a primitive type (number,
|
||||
@throw invalid_iterator.204 if iterators are for a primitive type (number,
|
||||
boolean, or string) where an out of range error can be detected easily;
|
||||
example: `"iterators out of range"`
|
||||
@throw std::bad_alloc if allocation for object, array, or string fails
|
||||
@ -2460,7 +2460,7 @@ class basic_json
|
||||
{
|
||||
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
|
||||
{
|
||||
JSON_THROW(std::out_of_range("iterators out of range"));
|
||||
JSON_THROW(invalid_iterator(204, "iterators out of range"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4507,9 +4507,9 @@ class basic_json
|
||||
|
||||
@throw std::domain_error if called on a `null` value; example: `"cannot
|
||||
use erase() with null"`
|
||||
@throw std::domain_error if called on iterators which does not belong to
|
||||
the current JSON value; example: `"iterators do not fit current value"`
|
||||
@throw std::out_of_range if called on a primitive type with invalid
|
||||
@throw invalid_iterator.203 if called on iterators which does not belong
|
||||
to the current JSON value; example: `"iterators do not fit current value"`
|
||||
@throw invalid_iterator.204 if called on a primitive type with invalid
|
||||
iterators (i.e., if `first != begin()` and `last != end()`); example:
|
||||
`"iterators out of range"`
|
||||
|
||||
@ -4540,7 +4540,7 @@ class basic_json
|
||||
// make sure iterator fits the current value
|
||||
if (this != first.m_object or this != last.m_object)
|
||||
{
|
||||
JSON_THROW(std::domain_error("iterators do not fit current value"));
|
||||
JSON_THROW(invalid_iterator(203, "iterators do not fit current value"));
|
||||
}
|
||||
|
||||
IteratorType result = end();
|
||||
@ -4555,7 +4555,7 @@ class basic_json
|
||||
{
|
||||
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
|
||||
{
|
||||
JSON_THROW(std::out_of_range("iterators out of range"));
|
||||
JSON_THROW(invalid_iterator(204, "iterators out of range"));
|
||||
}
|
||||
|
||||
if (is_string())
|
||||
|
@ -2418,7 +2418,7 @@ class basic_json
|
||||
@throw invalid_iterator.201 if iterators are not compatible; that is, do
|
||||
not belong to the same JSON value; example: `"iterators are not
|
||||
compatible"`
|
||||
@throw std::out_of_range if iterators are for a primitive type (number,
|
||||
@throw invalid_iterator.204 if iterators are for a primitive type (number,
|
||||
boolean, or string) where an out of range error can be detected easily;
|
||||
example: `"iterators out of range"`
|
||||
@throw std::bad_alloc if allocation for object, array, or string fails
|
||||
@ -2460,7 +2460,7 @@ class basic_json
|
||||
{
|
||||
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
|
||||
{
|
||||
JSON_THROW(std::out_of_range("iterators out of range"));
|
||||
JSON_THROW(invalid_iterator(204, "iterators out of range"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -4507,9 +4507,9 @@ class basic_json
|
||||
|
||||
@throw std::domain_error if called on a `null` value; example: `"cannot
|
||||
use erase() with null"`
|
||||
@throw std::domain_error if called on iterators which does not belong to
|
||||
the current JSON value; example: `"iterators do not fit current value"`
|
||||
@throw std::out_of_range if called on a primitive type with invalid
|
||||
@throw invalid_iterator.203 if called on iterators which does not belong
|
||||
to the current JSON value; example: `"iterators do not fit current value"`
|
||||
@throw invalid_iterator.204 if called on a primitive type with invalid
|
||||
iterators (i.e., if `first != begin()` and `last != end()`); example:
|
||||
`"iterators out of range"`
|
||||
|
||||
@ -4540,7 +4540,7 @@ class basic_json
|
||||
// make sure iterator fits the current value
|
||||
if (this != first.m_object or this != last.m_object)
|
||||
{
|
||||
JSON_THROW(std::domain_error("iterators do not fit current value"));
|
||||
JSON_THROW(invalid_iterator(203, "iterators do not fit current value"));
|
||||
}
|
||||
|
||||
IteratorType result = end();
|
||||
@ -4555,7 +4555,7 @@ class basic_json
|
||||
{
|
||||
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
|
||||
{
|
||||
JSON_THROW(std::out_of_range("iterators out of range"));
|
||||
JSON_THROW(invalid_iterator(204, "iterators out of range"));
|
||||
}
|
||||
|
||||
if (is_string())
|
||||
|
@ -1193,17 +1193,17 @@ TEST_CASE("constructors")
|
||||
{
|
||||
{
|
||||
json j = "foo";
|
||||
CHECK_THROWS_AS(json(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1211,17 +1211,17 @@ TEST_CASE("constructors")
|
||||
{
|
||||
{
|
||||
json j = false;
|
||||
CHECK_THROWS_AS(json(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1229,17 +1229,17 @@ TEST_CASE("constructors")
|
||||
{
|
||||
{
|
||||
json j = 17;
|
||||
CHECK_THROWS_AS(json(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1247,17 +1247,17 @@ TEST_CASE("constructors")
|
||||
{
|
||||
{
|
||||
json j = 17u;
|
||||
CHECK_THROWS_AS(json(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1265,17 +1265,17 @@ TEST_CASE("constructors")
|
||||
{
|
||||
{
|
||||
json j = 23.42;
|
||||
CHECK_THROWS_AS(json(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(json(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(json(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -406,35 +406,35 @@ 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()), std::domain_error);
|
||||
CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray.end()), std::domain_error);
|
||||
CHECK_THROWS_AS(jarray.erase(jarray2.begin(), jarray2.end()), std::domain_error);
|
||||
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");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray.begin(), jarray2.end()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray2.begin(), jarray.end()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray2.begin(), jarray2.end()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
}
|
||||
{
|
||||
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()), std::domain_error);
|
||||
CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray.cend()), std::domain_error);
|
||||
CHECK_THROWS_AS(jarray.erase(jarray2.cbegin(), jarray2.cend()), std::domain_error);
|
||||
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");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray.cbegin(), jarray2.cend()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray2.cbegin(), jarray.cend()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jarray.erase(jarray2.cbegin(), jarray2.cend()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -859,17 +859,17 @@ TEST_CASE("element access 1")
|
||||
{
|
||||
{
|
||||
json j = "foo";
|
||||
CHECK_THROWS_AS(j.erase(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -877,17 +877,17 @@ TEST_CASE("element access 1")
|
||||
{
|
||||
{
|
||||
json j = false;
|
||||
CHECK_THROWS_AS(j.erase(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -895,17 +895,17 @@ TEST_CASE("element access 1")
|
||||
{
|
||||
{
|
||||
json j = 17;
|
||||
CHECK_THROWS_AS(j.erase(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -913,17 +913,17 @@ TEST_CASE("element access 1")
|
||||
{
|
||||
{
|
||||
json j = 17u;
|
||||
CHECK_THROWS_AS(j.erase(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -931,17 +931,17 @@ TEST_CASE("element access 1")
|
||||
{
|
||||
{
|
||||
json j = 23.42;
|
||||
CHECK_THROWS_AS(j.erase(j.end(), j.end()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.begin(), j.begin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end(), j.end()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.begin(), j.begin()), "iterators out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_AS(j.erase(j.cbegin(), j.cbegin()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend(), j.cend()), "iterators out of range");
|
||||
CHECK_THROWS_WITH(j.erase(j.cbegin(), j.cbegin()), "iterators out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -686,33 +686,33 @@ 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()), std::domain_error);
|
||||
CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject.end()), std::domain_error);
|
||||
CHECK_THROWS_AS(jobject.erase(jobject2.begin(), jobject2.end()), std::domain_error);
|
||||
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()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jobject.erase(jobject2.begin(), jobject.end()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jobject.erase(jobject2.begin(), jobject2.end()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
}
|
||||
{
|
||||
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()), std::domain_error);
|
||||
CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject.cend()), std::domain_error);
|
||||
CHECK_THROWS_AS(jobject.erase(jobject2.cbegin(), jobject2.cend()), std::domain_error);
|
||||
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()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jobject.erase(jobject2.cbegin(), jobject.cend()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
CHECK_THROWS_WITH(jobject.erase(jobject2.cbegin(), jobject2.cend()),
|
||||
"iterators do not fit current value");
|
||||
"[json.exception.invalid_iterator.203] iterators do not fit current value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user