🐛 fix bug in diagnostics_t

This commit is contained in:
Niels Lohmann
2021-01-23 20:58:59 +01:00
parent 7b7da08fb6
commit 380a613f2b
3 changed files with 10 additions and 4 deletions

View File

@@ -95,4 +95,10 @@ TEST_CASE("Better diagnostics")
{
CHECK_THROWS_WITH_AS(json::parse(""), "[json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected end of input; expected '[', '{', or a literal", json::parse_error);
}
SECTION("Regression test for https://github.com/nlohmann/json/pull/2562#pullrequestreview-574858448")
{
CHECK_THROWS_WITH_AS(json({"0", "0"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
CHECK_THROWS_WITH_AS(json({"0", "1"})[1].get<int>(), "[json.exception.type_error.302] (/1) type must be number, but is string", json::type_error);
}
}