improve coverage

This commit is contained in:
Niels Lohmann 2021-01-17 22:52:40 +01:00
parent 5ec0980514
commit 33379684b4
No known key found for this signature in database
GPG Key ID: 7F3CEA63AE251B69
3 changed files with 13 additions and 6 deletions

View File

@ -58,14 +58,14 @@ class diagnostics_t
break;
}
default:
break;
default: // LCOV_EXCL_LINE
break; // LCOV_EXCL_LINE
}
}
if (tokens.empty())
{
return "";
return ""; // LCOV_EXCL_LINE
}
return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},

View File

@ -2556,14 +2556,14 @@ class diagnostics_t
break;
}
default:
break;
default: // LCOV_EXCL_LINE
break; // LCOV_EXCL_LINE
}
}
if (tokens.empty())
{
return "";
return ""; // LCOV_EXCL_LINE
}
return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{},

View File

@ -40,6 +40,13 @@ using nlohmann::json;
TEST_CASE("Better diagnostics")
{
SECTION("empty JSON Pointer")
{
json j = 1;
std::string s;
CHECK_THROWS_WITH_AS(s = j.get<std::string>(), "[json.exception.type_error.302] type must be string, but is number", json::type_error);
}
SECTION("invalid type")
{
json j;