🔨 added user-defined exceptions 401-402

This commit is contained in:
Niels Lohmann
2017-03-05 22:56:39 +01:00
parent 491c9780a7
commit 60da36aee2
5 changed files with 75 additions and 60 deletions

View File

@@ -63,11 +63,13 @@ TEST_CASE("element access 1")
SECTION("access outside bounds")
{
CHECK_THROWS_AS(j.at(8), std::out_of_range);
CHECK_THROWS_AS(j_const.at(8), std::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), "array index 8 is out of range");
CHECK_THROWS_WITH(j_const.at(8), "array index 8 is out of range");
CHECK_THROWS_WITH(j.at(8),
"[json.exception.out_of_range.401] array index 8 is out of range");
CHECK_THROWS_WITH(j_const.at(8),
"[json.exception.out_of_range.401] array index 8 is out of range");
}
SECTION("access on non-array type")
@@ -311,8 +313,9 @@ 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), std::out_of_range);
CHECK_THROWS_WITH(jarray.erase(8), "array index 8 is 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");
}
}