mirror of
https://github.com/nlohmann/json.git
synced 2026-03-16 05:56:00 +00:00
🔨 added user-defined exceptions 205-206
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user