improved test coverage

This commit is contained in:
Niels Lohmann 2018-01-14 17:22:06 +01:00
parent 6965ff00c8
commit f85f4967fe
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
6 changed files with 298 additions and 152 deletions

View file

@ -1213,7 +1213,7 @@ class binary_reader
{
get();
check_eof();
if (JSON_UNLIKELY(not(0 <= current and current <= 127)))
if (JSON_UNLIKELY(current > 127))
{
std::stringstream ss;
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
@ -1286,10 +1286,9 @@ class binary_reader
{
if (size_and_type.second != 0)
{
if (size_and_type.second != 'N')
std::generate_n(std::inserter(*result.m_value.object,
result.m_value.object->end()),
size_and_type.first, [this, size_and_type]()
std::generate_n(std::inserter(*result.m_value.object,
result.m_value.object->end()),
size_and_type.first, [this, size_and_type]()
{
auto key = get_ubjson_string();
auto val = get_ubjson_value(size_and_type.second);

View file

@ -759,8 +759,7 @@ class binary_writer
}
else
{
// TODO: replace by exception
assert(false);
JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
}
}
else
@ -805,11 +804,12 @@ class binary_writer
}
write_number(static_cast<int64_t>(n));
}
// LCOV_EXCL_START
else
{
// TODO: replace by exception
assert(false);
JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
}
// LCOV_EXCL_STOP
}
}