Count matching keys as unsigned in the json_view edit tests

Like in the access test, adding the int result of the conditional to a
std::size_t fails -Werror=sign-conversion with GCC.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-18 13:32:10 +02:00
1 parent acd92f9c09
commit 34d54b6363
1 file changed
+2 -2
+2 -2
View File
@@ -229,7 +229,7 @@ std::size_t occurrences(const ordered_json_editable_view& v, const std::string&
std::size_t result = 0;
for (const auto& item : v.items())
{
result += std::string(item.key().data(), item.key().size()) == key ? 1 : 0;
result += std::string(item.key().data(), item.key().size()) == key ? 1u : 0u;
}
return result;
}
@@ -977,7 +977,7 @@ void check_first_wins(const View& o, int expected)
std::size_t members_a = 0;
for (const auto& item : o.items())
{
members_a += std::string(item.key().data(), item.key().size()) == "a" ? 1 : 0;
members_a += std::string(item.key().data(), item.key().size()) == "a" ? 1u : 0u;
}
CHECK(o.count("a") == members_a); // every member, unlike the lookups
}