From 5199259a634e9361b2f561f31d1d62afc2ff4c7e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 29 Sep 2026 02:34:54 +0200 Subject: [PATCH] Mark the cases of the view's serializer that tests cannot reach Signed-off-by: Niels Lohmann --- include/nlohmann/detail/view/serializer.hpp | 14 +++++++------- single_include/nlohmann/json_view.hpp | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/nlohmann/detail/view/serializer.hpp b/include/nlohmann/detail/view/serializer.hpp index 38377e9c0..98c7335dd 100644 --- a/include/nlohmann/detail/view/serializer.hpp +++ b/include/nlohmann/detail/view/serializer.hpp @@ -259,12 +259,12 @@ class view_serializer write_float(float_value(m_doc.str(n), n)); } break; - case value_t::object: - case value_t::array: - case value_t::binary: - case value_t::discarded: - default: - break; + case value_t::object: // LCOV_EXCL_LINE (containers are written by dump()) + case value_t::array: // LCOV_EXCL_LINE + case value_t::binary: // LCOV_EXCL_LINE (not in a document) + case value_t::discarded: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + break; // LCOV_EXCL_LINE } } @@ -399,7 +399,7 @@ class view_serializer } return; } - m_out.put(reinterpret_cast(bytes), len); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + m_out.put(reinterpret_cast(bytes), len); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) LCOV_EXCL_LINE (printable characters are copied in runs) } void write_u_escape(std::uint32_t u) diff --git a/single_include/nlohmann/json_view.hpp b/single_include/nlohmann/json_view.hpp index 9d0ab3b2e..c18252304 100644 --- a/single_include/nlohmann/json_view.hpp +++ b/single_include/nlohmann/json_view.hpp @@ -2832,12 +2832,12 @@ class view_serializer write_float(float_value(m_doc.str(n), n)); } break; - case value_t::object: - case value_t::array: - case value_t::binary: - case value_t::discarded: - default: - break; + case value_t::object: // LCOV_EXCL_LINE (containers are written by dump()) + case value_t::array: // LCOV_EXCL_LINE + case value_t::binary: // LCOV_EXCL_LINE (not in a document) + case value_t::discarded: // LCOV_EXCL_LINE + default: // LCOV_EXCL_LINE + break; // LCOV_EXCL_LINE } } @@ -2972,7 +2972,7 @@ class view_serializer } return; } - m_out.put(reinterpret_cast(bytes), len); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) + m_out.put(reinterpret_cast(bytes), len); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) LCOV_EXCL_LINE (printable characters are copied in runs) } void write_u_escape(std::uint32_t u)