mirror of
https://github.com/nlohmann/json.git
synced 2026-11-02 19:05:35 +00:00
Fix ci_clang_tidy and ci_test_noexceptions for the BSON writer
ci_clang_tidy (modernize-use-auto) flagged the cast initialization in bson_entry_fits(); ci_test_noexceptions aborted in the "errors at every position" section of unit-bson.cpp, whose entries all throw, so that section now needs exceptions like the rest of the error checks. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
3 files changed
+5
-2
No files matched your search
@@ -2400,7 +2400,7 @@ class binary_writer
|
|||||||
/// the 32-bit size of BSON
|
/// the 32-bit size of BSON
|
||||||
bool bson_entry_fits(const std::size_t start, const std::size_t entry_size, const std::size_t open_containers) const noexcept
|
bool bson_entry_fits(const std::size_t start, const std::size_t entry_size, const std::size_t open_containers) const noexcept
|
||||||
{
|
{
|
||||||
const std::size_t limit = static_cast<std::size_t>((std::numeric_limits<std::int32_t>::max)());
|
const auto limit = static_cast<std::size_t>((std::numeric_limits<std::int32_t>::max)());
|
||||||
const std::size_t written = oa.written() - start;
|
const std::size_t written = oa.written() - start;
|
||||||
return written <= limit && entry_size <= limit - written && open_containers <= limit - written - entry_size;
|
return written <= limit && entry_size <= limit - written && open_containers <= limit - written - entry_size;
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1
-1
@@ -29649,7 +29649,7 @@ class binary_writer
|
|||||||
/// the 32-bit size of BSON
|
/// the 32-bit size of BSON
|
||||||
bool bson_entry_fits(const std::size_t start, const std::size_t entry_size, const std::size_t open_containers) const noexcept
|
bool bson_entry_fits(const std::size_t start, const std::size_t entry_size, const std::size_t open_containers) const noexcept
|
||||||
{
|
{
|
||||||
const std::size_t limit = static_cast<std::size_t>((std::numeric_limits<std::int32_t>::max)());
|
const auto limit = static_cast<std::size_t>((std::numeric_limits<std::int32_t>::max)());
|
||||||
const std::size_t written = oa.written() - start;
|
const std::size_t written = oa.written() - start;
|
||||||
return written <= limit && entry_size <= limit - written && open_containers <= limit - written - entry_size;
|
return written <= limit && entry_size <= limit - written && open_containers <= limit - written - entry_size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2357,6 +2357,8 @@ TEST_CASE("BSON written in one pass and in two passes")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(JSON_NOEXCEPTION)
|
||||||
|
// every entry here throws, which aborts without exceptions
|
||||||
SECTION("errors at every position")
|
SECTION("errors at every position")
|
||||||
{
|
{
|
||||||
// an entry that cannot be written, at each place among valid ones
|
// an entry that cannot be written, at each place among valid ones
|
||||||
@@ -2395,4 +2397,5 @@ TEST_CASE("BSON written in one pass and in two passes")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user