🔨 added user-defined exceptions 205-206
This commit is contained in:
parent
875b2da95d
commit
a4274d7766
6 changed files with 102 additions and 98 deletions
|
@ -1106,13 +1106,15 @@ TEST_CASE("constructors")
|
|||
{
|
||||
{
|
||||
json j;
|
||||
CHECK_THROWS_AS(json(j.begin(), j.end()), std::domain_error);
|
||||
CHECK_THROWS_WITH(json(j.begin(), j.end()), "cannot use construct with iterators from null");
|
||||
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()), std::domain_error);
|
||||
CHECK_THROWS_WITH(json(j.cbegin(), j.cend()), "cannot use construct with iterators from null");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -689,13 +689,13 @@ TEST_CASE("element access 1")
|
|||
{
|
||||
{
|
||||
json j = "foo";
|
||||
CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -703,13 +703,13 @@ TEST_CASE("element access 1")
|
|||
{
|
||||
{
|
||||
json j = false;
|
||||
CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
|
||||
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 = 17;
|
||||
CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -731,13 +731,13 @@ TEST_CASE("element access 1")
|
|||
{
|
||||
{
|
||||
json j = 17u;
|
||||
CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,13 +745,13 @@ TEST_CASE("element access 1")
|
|||
{
|
||||
{
|
||||
json j = 23.42;
|
||||
CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
|
||||
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()), std::out_of_range);
|
||||
CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -229,22 +229,22 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
@ -433,22 +433,22 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
@ -630,11 +630,11 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK(cit.value() == json(1));
|
||||
}
|
||||
}
|
||||
|
@ -1007,22 +1007,22 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
@ -1211,22 +1211,22 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
@ -1415,22 +1415,22 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
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(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
@ -1489,24 +1489,24 @@ TEST_CASE("iterators 1")
|
|||
{
|
||||
auto it = j.begin();
|
||||
auto cit = j_const.cbegin();
|
||||
CHECK_THROWS_AS(it.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(it.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(it.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(cit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(cit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(it.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(cit.value(), "cannot get value");
|
||||
|
||||
auto rit = j.rend();
|
||||
auto crit = j.crend();
|
||||
CHECK_THROWS_AS(rit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(rit.value(), std::out_of_range);
|
||||
CHECK_THROWS_AS(crit.key(), std::domain_error);
|
||||
CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(crit.value(), std::out_of_range);
|
||||
CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(rit.value(), "cannot get value");
|
||||
CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
|
||||
CHECK_THROWS_WITH(crit.value(), "cannot get value");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -380,17 +380,17 @@ TEST_CASE("iterators 2")
|
|||
{
|
||||
{
|
||||
auto it = j_object.begin();
|
||||
CHECK_THROWS_AS(it[0], std::domain_error);
|
||||
CHECK_THROWS_AS(it[1], std::domain_error);
|
||||
CHECK_THROWS_WITH(it[0], "cannot use operator[] for object iterators");
|
||||
CHECK_THROWS_WITH(it[1], "cannot use operator[] for object iterators");
|
||||
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], std::domain_error);
|
||||
CHECK_THROWS_AS(it[1], std::domain_error);
|
||||
CHECK_THROWS_WITH(it[0], "cannot use operator[] for object iterators");
|
||||
CHECK_THROWS_WITH(it[1], "cannot use operator[] for object iterators");
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue