CHECK_THROWS_WITH_AS(s=j["a"]["b"]["c"].get<std::string>(),"[json.exception.type_error.302] (/a/b/c) type must be string, but is number",json::type_error);
CHECK_THROWS_WITH_AS(j["object"].at("not_found"),"[json.exception.out_of_range.403] (/object) key 'not_found' not found",json::out_of_range);
}
SECTION("array index out of range")
{
jsonj;
j["array"][4]=true;
CHECK_THROWS_WITH_AS(j["array"].at(5),"[json.exception.out_of_range.401] (/array) array index 5 is out of range",json::out_of_range);
}
SECTION("array index at wrong type")
{
jsonj;
j["array"][4]=true;
CHECK_THROWS_WITH_AS(j["array"][4][5],"[json.exception.type_error.305] (/array/4) cannot use operator[] with a numeric argument with boolean",json::type_error);
}
SECTION("wrong iterator")
{
jsonj;
j["array"]=json::array();
CHECK_THROWS_WITH_AS(j["array"].erase(j.begin()),"[json.exception.invalid_iterator.202] (/array) iterator does not fit current value",json::invalid_iterator);
CHECK_THROWS_WITH_AS(s=j["a/b"]["m~n"].get<std::string>(),"[json.exception.type_error.302] (/a~1b/m~0n) type must be string, but is number",json::type_error);