improved test coverage

parent 6965ff00
...@@ -278,11 +278,6 @@ script: ...@@ -278,11 +278,6 @@ script:
- ctest -C Release -V -j - ctest -C Release -V -j
- cd .. - cd ..
# check if header was correctly amalgamated
- if [ `which python` ]; then
make check-amalgamation ;
fi
# check if homebrew works (only checks develop branch) # check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then - if [ `which brew` ]; then
brew update ; brew update ;
......
...@@ -263,6 +263,7 @@ json.exception.out_of_range.403 | key 'foo' not found | The provided key was not ...@@ -263,6 +263,7 @@ json.exception.out_of_range.403 | key 'foo' not found | The provided key was not
json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON only supports integers numbers up to 9223372036854775807. |
@liveexample{The following code shows how an `out_of_range` exception can be @liveexample{The following code shows how an `out_of_range` exception can be
caught.,out_of_range} caught.,out_of_range}
......
...@@ -1213,7 +1213,7 @@ class binary_reader ...@@ -1213,7 +1213,7 @@ class binary_reader
{ {
get(); get();
check_eof(); check_eof();
if (JSON_UNLIKELY(not(0 <= current and current <= 127))) if (JSON_UNLIKELY(current > 127))
{ {
std::stringstream ss; std::stringstream ss;
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
...@@ -1286,10 +1286,9 @@ class binary_reader ...@@ -1286,10 +1286,9 @@ class binary_reader
{ {
if (size_and_type.second != 0) if (size_and_type.second != 0)
{ {
if (size_and_type.second != 'N') std::generate_n(std::inserter(*result.m_value.object,
std::generate_n(std::inserter(*result.m_value.object, result.m_value.object->end()),
result.m_value.object->end()), size_and_type.first, [this, size_and_type]()
size_and_type.first, [this, size_and_type]()
{ {
auto key = get_ubjson_string(); auto key = get_ubjson_string();
auto val = get_ubjson_value(size_and_type.second); auto val = get_ubjson_value(size_and_type.second);
......
...@@ -759,8 +759,7 @@ class binary_writer ...@@ -759,8 +759,7 @@ class binary_writer
} }
else else
{ {
// TODO: replace by exception JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
assert(false);
} }
} }
else else
...@@ -805,11 +804,12 @@ class binary_writer ...@@ -805,11 +804,12 @@ class binary_writer
} }
write_number(static_cast<int64_t>(n)); write_number(static_cast<int64_t>(n));
} }
// LCOV_EXCL_START
else else
{ {
// TODO: replace by exception JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
assert(false);
} }
// LCOV_EXCL_STOP
} }
} }
......
...@@ -715,6 +715,7 @@ json.exception.out_of_range.403 | key 'foo' not found | The provided key was not ...@@ -715,6 +715,7 @@ json.exception.out_of_range.403 | key 'foo' not found | The provided key was not
json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved.
json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value.
json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF.
json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON only supports integers numbers up to 9223372036854775807. |
@liveexample{The following code shows how an `out_of_range` exception can be @liveexample{The following code shows how an `out_of_range` exception can be
caught.,out_of_range} caught.,out_of_range}
...@@ -6001,7 +6002,7 @@ class binary_reader ...@@ -6001,7 +6002,7 @@ class binary_reader
{ {
get(); get();
check_eof(); check_eof();
if (JSON_UNLIKELY(not(0 <= current and current <= 127))) if (JSON_UNLIKELY(current > 127))
{ {
std::stringstream ss; std::stringstream ss;
ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current; ss << std::setw(2) << std::uppercase << std::setfill('0') << std::hex << current;
...@@ -6074,10 +6075,9 @@ class binary_reader ...@@ -6074,10 +6075,9 @@ class binary_reader
{ {
if (size_and_type.second != 0) if (size_and_type.second != 0)
{ {
if (size_and_type.second != 'N') std::generate_n(std::inserter(*result.m_value.object,
std::generate_n(std::inserter(*result.m_value.object, result.m_value.object->end()),
result.m_value.object->end()), size_and_type.first, [this, size_and_type]()
size_and_type.first, [this, size_and_type]()
{ {
auto key = get_ubjson_string(); auto key = get_ubjson_string();
auto val = get_ubjson_value(size_and_type.second); auto val = get_ubjson_value(size_and_type.second);
...@@ -6911,8 +6911,7 @@ class binary_writer ...@@ -6911,8 +6911,7 @@ class binary_writer
} }
else else
{ {
// TODO: replace by exception JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
assert(false);
} }
} }
else else
...@@ -6957,11 +6956,12 @@ class binary_writer ...@@ -6957,11 +6956,12 @@ class binary_writer
} }
write_number(static_cast<int64_t>(n)); write_number(static_cast<int64_t>(n));
} }
// LCOV_EXCL_START
else else
{ {
// TODO: replace by exception JSON_THROW(out_of_range::create(407, "number overflow serializing " + std::to_string(n)));
assert(false);
} }
// LCOV_EXCL_STOP
} }
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment