mirror of
https://github.com/nlohmann/json.git
synced 2026-10-28 08:45:43 +00:00
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:
1 parent
eb8f675bc9
commit
8617d9c94c
3 files changed
+11
-6
No files matched your search
@@ -1311,7 +1311,7 @@ TEST_CASE("BSON declared document size bounds the content")
|
|||||||
// records the events that a SAX parser receives
|
// records the events that a SAX parser receives
|
||||||
struct recorder : nlohmann::json_sax<json>
|
struct recorder : nlohmann::json_sax<json>
|
||||||
{
|
{
|
||||||
std::string events;
|
std::string events {};
|
||||||
|
|
||||||
bool null() override
|
bool null() override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2178,8 +2178,13 @@ TEST_CASE("JSON patch - behavior documented in the API reference")
|
|||||||
|
|
||||||
SECTION("patch() has the strong guarantee")
|
SECTION("patch() has the strong guarantee")
|
||||||
{
|
{
|
||||||
const json doc = R"({"a": [1, 2], "o": {"k": "v"}})"_json;
|
// independent values, so that the comparison below checks the untouched document
|
||||||
const json before = doc;
|
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 =
|
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_THROWS_AS(doc.patch(patch), json::exception&);
|
||||||
CHECK(doc == before);
|
CHECK(doc == before);
|
||||||
|
|
||||||
json copy = doc;
|
json copy = make_doc();
|
||||||
CHECK_THROWS_AS(copy.patch(patch), json::exception&);
|
CHECK_THROWS_AS(copy.patch(patch), json::exception&);
|
||||||
CHECK(copy == before);
|
CHECK(copy == before);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ TEST_CASE("json_view node integer bits")
|
|||||||
})
|
})
|
||||||
{
|
{
|
||||||
CAPTURE(v)
|
CAPTURE(v)
|
||||||
n.kind = static_cast<nlohmann::detail::view::node_kind>(0x5A);
|
n.kind = nlohmann::detail::view::node_kind::link;
|
||||||
n.flags = 0xA5;
|
n.flags = 0xA5;
|
||||||
n.extra = 0x1234;
|
n.extra = 0x1234;
|
||||||
n.off = 0x89ABCDEFu;
|
n.off = 0x89ABCDEFu;
|
||||||
@@ -601,7 +601,7 @@ TEST_CASE("json_view node integer bits")
|
|||||||
CHECK(n.len == static_cast<std::uint32_t>(v));
|
CHECK(n.len == static_cast<std::uint32_t>(v));
|
||||||
CHECK(n.next == static_cast<std::uint32_t>(v >> 32));
|
CHECK(n.next == static_cast<std::uint32_t>(v >> 32));
|
||||||
// the other fields are untouched
|
// the other fields are untouched
|
||||||
CHECK(static_cast<std::uint8_t>(n.kind) == 0x5A);
|
CHECK(n.kind == nlohmann::detail::view::node_kind::link);
|
||||||
CHECK(n.flags == 0xA5);
|
CHECK(n.flags == 0xA5);
|
||||||
CHECK(n.extra == 0x1234);
|
CHECK(n.extra == 0x1234);
|
||||||
CHECK(n.off == 0x89ABCDEFu);
|
CHECK(n.off == 0x89ABCDEFu);
|
||||||
|
|||||||
Reference in new issue
Block a user