diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp
index 8b864b57..0c6185e0 100644
--- a/include/nlohmann/detail/output/binary_writer.hpp
+++ b/include/nlohmann/detail/output/binary_writer.hpp
@@ -1434,7 +1434,7 @@ class binary_writer
                     return 'L';
                 }
                 // anything else is treated as high-precision number
-                return 'H';
+                return 'H'; // LCOV_EXCL_LINE
             }
 
             case value_t::number_unsigned:
@@ -1460,7 +1460,7 @@ class binary_writer
                     return 'L';
                 }
                 // anything else is treated as high-precision number
-                return 'H';
+                return 'H'; // LCOV_EXCL_LINE
             }
 
             case value_t::number_float:
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp
index a845846a..9770712a 100644
--- a/single_include/nlohmann/json.hpp
+++ b/single_include/nlohmann/json.hpp
@@ -14153,7 +14153,7 @@ class binary_writer
                     return 'L';
                 }
                 // anything else is treated as high-precision number
-                return 'H';
+                return 'H'; // LCOV_EXCL_LINE
             }
 
             case value_t::number_unsigned:
@@ -14179,7 +14179,7 @@ class binary_writer
                     return 'L';
                 }
                 // anything else is treated as high-precision number
-                return 'H';
+                return 'H'; // LCOV_EXCL_LINE
             }
 
             case value_t::number_float:
diff --git a/test/src/unit-ubjson.cpp b/test/src/unit-ubjson.cpp
index c8b5f6bc..d55f52e8 100644
--- a/test/src/unit-ubjson.cpp
+++ b/test/src/unit-ubjson.cpp
@@ -797,12 +797,19 @@ TEST_CASE("UBJSON")
 
                 SECTION("errors")
                 {
-                    std::vector<uint8_t> vec1 = {'H', 'i', 2, '1', 'A', '3'};
-                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec1), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
-                    std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', '.'};
-                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
-                    std::vector<uint8_t> vec3 = {'H', 2, '1', '0'};
-                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec3), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
+                    // error while parsing length
+                    std::vector<uint8_t> vec0 = {'H', 'i'};
+                    CHECK(json::from_ubjson(vec0, true, false).is_discarded());
+                    // error while parsing string
+                    std::vector<uint8_t> vec1 = {'H', 'i', '1'};
+                    CHECK(json::from_ubjson(vec1, true, false).is_discarded());
+
+                    std::vector<uint8_t> vec2 = {'H', 'i', 2, '1', 'A', '3'};
+                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec2), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A", json::parse_error);
+                    std::vector<uint8_t> vec3 = {'H', 'i', 2, '1', '.'};
+                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec3), "[json.exception.parse_error.115] parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1.", json::parse_error);
+                    std::vector<uint8_t> vec4 = {'H', 2, '1', '0'};
+                    CHECK_THROWS_WITH_AS(json::from_ubjson(vec4), "[json.exception.parse_error.113] parse error at byte 2: syntax error while parsing UBJSON size: expected length type specification (U, i, I, l, L) after '#'; last byte: 0x02", json::parse_error);
                 }
 
                 SECTION("serialization")