diff --git a/include/nlohmann/json_view.hpp b/include/nlohmann/json_view.hpp index 39e7f86b1..e6b0aeec8 100644 --- a/include/nlohmann/json_view.hpp +++ b/include/nlohmann/json_view.hpp @@ -734,7 +734,7 @@ class basic_json_view // the end is unknown: assume a few bytes per node, the output buffer // grows should the value be larger const auto nodes = static_cast(document_data::after(m_node) - m_node); - return (std::min)(m_doc->size - m_node->off, static_cast(1024) + nodes * 16); + return (std::min)(m_doc->size - m_node->off, static_cast(1024) + (nodes * 16)); } /// the value of the first member with this key, or a discarded view diff --git a/tests/src/unit-json_view.cpp b/tests/src/unit-json_view.cpp index 0acee0090..9904a72ce 100644 --- a/tests/src/unit-json_view.cpp +++ b/tests/src/unit-json_view.cpp @@ -1509,10 +1509,10 @@ TEST_CASE("json_view dump") { chars += "\xC3\xA9"; } - const json_document d = json_document::parse("{\"a\":\"" + chars + R"(","k\n":1})"); + const json_document d = json_document::parse(R"({"a":")" + chars + R"(","k\n":1})"); const json expected = json::parse("\"" + chars + "\""); CHECK(d.root()["a"].dump(-1, ' ', true) == expected.dump(-1, ' ', true)); - CHECK(d.root()["a"].dump(-1, ' ', true).size() == 2 + 5000 * 6); + CHECK(d.root()["a"].dump(-1, ' ', true).size() == 2 + (5000 * 6)); } SECTION("streams and discarded views") @@ -1604,7 +1604,7 @@ TEST_CASE("json_view comparison") // discarded values compare as basic_json's do const json discarded(json::value_t::discarded); CHECK((json_view() == json_view()) == (discarded == discarded)); // NOLINT(readability-container-size-empty): operator== is tested - CHECK((json_view() == discarded) == (discarded == discarded)); + CHECK((json_view() == discarded) == (discarded == discarded)); // NOLINT(readability-container-size-empty) const json_document null_document = json_document::parse("null"); CHECK(!(json_view() == null_document.root())); // NOLINT(readability-container-size-empty) CHECK(!(null_document.root() == discarded));