Fix CI: clang-tidy, unused result, Infer false positive in tests
- unit-deserialization.cpp: raw string literals, and assign the result of parse() in CHECK_THROWS_AS (-Wunused-result) - unit-bson.cpp: mark Infer's NULLPTR_DEREFERENCE on from_bson() with an iterator pair as a false positive Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+5
-2
No files matched your search
@@ -1674,6 +1674,8 @@ TEST_CASE("BSON input that cannot be read is discarded by every overload")
|
|||||||
json _;
|
json _;
|
||||||
CHECK_THROWS_AS(_ = json::from_bson(input.begin(), input.end()), json::parse_error&);
|
CHECK_THROWS_AS(_ = json::from_bson(input.begin(), input.end()), json::parse_error&);
|
||||||
CHECK(json::from_bson(input, true, false).is_discarded());
|
CHECK(json::from_bson(input, true, false).is_discarded());
|
||||||
|
// false positive: Infer takes std::integral_constant<bool, false>::value for a pointer
|
||||||
|
// @infer-ignore NULLPTR_DEREFERENCE
|
||||||
CHECK(json::from_bson(input.begin(), input.end(), true, false).is_discarded());
|
CHECK(json::from_bson(input.begin(), input.end(), true, false).is_discarded());
|
||||||
#ifndef JSON_TEST_DEPRECATED_FUNCTIONS_DELETED
|
#ifndef JSON_TEST_DEPRECATED_FUNCTIONS_DELETED
|
||||||
CHECK(json::from_bson(input.data(), input.size(), true, false).is_discarded());
|
CHECK(json::from_bson(input.data(), input.size(), true, false).is_discarded());
|
||||||
|
|||||||
@@ -1457,7 +1457,7 @@ TEST_CASE("deserialization from iterator pairs of std::string and std::vector")
|
|||||||
// these are read as the pointer range they are, also before C++20
|
// these are read as the pointer range they are, also before C++20
|
||||||
for (const char* text :
|
for (const char* text :
|
||||||
{
|
{
|
||||||
"", " ", "[1, 2.5, \"a\", true, null, {\"k\": [\"v\"]}]", "[1, 2", "{\"a\" 1}", "\"\xC3\xA4\"", "\"\xC3\"", "[1]x", "1e400"
|
"", " ", R"([1, 2.5, "a", true, null, {"k": ["v"]}])", "[1, 2", R"({"a" 1})", "\"\xC3\xA4\"", "\"\xC3\"", "[1]x", "1e400"
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
check_iterator_pairs(text);
|
check_iterator_pairs(text);
|
||||||
@@ -1467,6 +1467,7 @@ TEST_CASE("deserialization from iterator pairs of std::string and std::vector")
|
|||||||
// an empty range is not dereferenced
|
// an empty range is not dereferenced
|
||||||
std::string empty;
|
std::string empty;
|
||||||
CHECK_FALSE(json::accept(empty.begin(), empty.end()));
|
CHECK_FALSE(json::accept(empty.begin(), empty.end()));
|
||||||
CHECK_THROWS_AS(json::parse(empty.begin(), empty.end()), json::parse_error&);
|
json _;
|
||||||
|
CHECK_THROWS_AS(_ = json::parse(empty.begin(), empty.end()), json::parse_error&);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user