Fix test lints that are red on develop (effc++, clang-tidy) (#5946)

- unit-bson: initialize the SAX recorder's member (-Weffc++)
- unit-json_patch: build the reference document independently instead of
  copying it (performance-unnecessary-copy-initialization)
- unit-json_view_builder: use node_kind::link instead of an out-of-range
  enum cast (clang-analyzer-optin.core.EnumCastOutOfRange)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann authored and GitHub committed 2026-10-27 17:25:18 +01:00
1 parent eb8f675bc9
commit 8617d9c94c
3 files changed
+11 -6

No files matched your search

+8 -3
View File
@@ -2178,8 +2178,13 @@ TEST_CASE("JSON patch - behavior documented in the API reference")
SECTION("patch() has the strong guarantee")
{
const json doc = R"({"a": [1, 2], "o": {"k": "v"}})"_json;
const json before = doc;
// independent values, so that the comparison below checks the untouched document
const auto make_doc = []
{
return R"({"a": [1, 2], "o": {"k": "v"}})"_json;
};
const json doc = make_doc();
const json before = make_doc();
const std::vector<json> failing =
{
@@ -2202,7 +2207,7 @@ TEST_CASE("JSON patch - behavior documented in the API reference")
CHECK_THROWS_AS(doc.patch(patch), json::exception&);
CHECK(doc == before);
json copy = doc;
json copy = make_doc();
CHECK_THROWS_AS(copy.patch(patch), json::exception&);
CHECK(copy == before);
}