🚧 add tests

This commit is contained in:
Niels Lohmann
2021-01-02 16:13:04 +01:00
parent 09cd4ed125
commit 7323a8eb4e
6 changed files with 262 additions and 162 deletions

View File

@@ -12900,7 +12900,7 @@ class binary_writer
default:
{
JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
JSON_THROW(type_error::create(317, j.diagnostics() + "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
}
}
}
@@ -13744,12 +13744,12 @@ class binary_writer
@return The size of a BSON document entry header, including the id marker
and the entry name size (and its null-terminator).
*/
static std::size_t calc_bson_entry_header_size(const string_t& name)
static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j)
{
const auto it = name.find(static_cast<typename string_t::value_type>(0));
if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
{
JSON_THROW(out_of_range::create(409,
JSON_THROW(out_of_range::create(409, j.diagnostics() +
"BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")"));
}
@@ -13860,21 +13860,21 @@ class binary_writer
@brief Writes a BSON element with key @a name and unsigned @a value
*/
void write_bson_unsigned(const string_t& name,
const std::uint64_t value)
const BasicJsonType& j)
{
if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
{
write_bson_entry_header(name, 0x10 /* int32 */);
write_number<std::int32_t, true>(static_cast<std::int32_t>(value));
write_number<std::int32_t, true>(static_cast<std::int32_t>(j.m_value.number_unsigned));
}
else if (value <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
else if (j.m_value.number_unsigned <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
{
write_bson_entry_header(name, 0x12 /* int64 */);
write_number<std::int64_t, true>(static_cast<std::int64_t>(value));
write_number<std::int64_t, true>(static_cast<std::int64_t>(j.m_value.number_unsigned));
}
else
{
JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(value) + " cannot be represented by BSON as it does not fit int64"));
JSON_THROW(out_of_range::create(407, j.diagnostics() + "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64"));
}
}
@@ -13951,7 +13951,7 @@ class binary_writer
static std::size_t calc_bson_element_size(const string_t& name,
const BasicJsonType& j)
{
const auto header_size = calc_bson_entry_header_size(name);
const auto header_size = calc_bson_entry_header_size(name, j);
switch (j.type())
{
case value_t::object:
@@ -14020,7 +14020,7 @@ class binary_writer
return write_bson_integer(name, j.m_value.number_integer);
case value_t::number_unsigned:
return write_bson_unsigned(name, j.m_value.number_unsigned);
return write_bson_unsigned(name, j);
case value_t::string:
return write_bson_string(name, *j.m_value.string);
@@ -18565,7 +18565,7 @@ class basic_json
// make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(201, "iterators are not compatible"));
JSON_THROW(invalid_iterator::create(201, diagnostics() + "iterators are not compatible"));
}
// copy type from first iterator
@@ -19398,7 +19398,7 @@ class basic_json
return m_value.boolean;
}
JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name())));
JSON_THROW(type_error::create(302, diagnostics() + "type must be boolean, but is " + std::string(type_name())));
}
/// get a pointer to the value (object)
@@ -19519,7 +19519,7 @@ class basic_json
return *ptr;
}
JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name())));
JSON_THROW(type_error::create(303, obj.diagnostics() + "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name())));
}
public:
@@ -19947,7 +19947,7 @@ class basic_json
{
if (!is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
JSON_THROW(type_error::create(302, diagnostics() + "type must be binary, but is " + std::string(type_name())));
}
return *get_ptr<binary_t*>();
@@ -19958,7 +19958,7 @@ class basic_json
{
if (!is_binary())
{
JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name())));
JSON_THROW(type_error::create(302, diagnostics() + "type must be binary, but is " + std::string(type_name())));
}
return *get_ptr<const binary_t*>();
@@ -20019,12 +20019,12 @@ class basic_json
JSON_CATCH (std::out_of_range&)
{
// create better exception explanation
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
JSON_THROW(out_of_range::create(401, diagnostics() + "array index " + std::to_string(idx) + " is out of range"));
}
}
else
{
JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
JSON_THROW(type_error::create(304, diagnostics() + "cannot use at() with " + std::string(type_name())));
}
}
@@ -20066,12 +20066,12 @@ class basic_json
JSON_CATCH (std::out_of_range&)
{
// create better exception explanation
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
JSON_THROW(out_of_range::create(401, diagnostics() + "array index " + std::to_string(idx) + " is out of range"));
}
}
else
{
JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
JSON_THROW(type_error::create(304, diagnostics() + "cannot use at() with " + std::string(type_name())));
}
}
@@ -20123,12 +20123,12 @@ class basic_json
JSON_CATCH (std::out_of_range&)
{
// create better exception explanation
JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
JSON_THROW(out_of_range::create(403, diagnostics() + "key '" + key + "' not found"));
}
}
else
{
JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
JSON_THROW(type_error::create(304, diagnostics() + "cannot use at() with " + std::string(type_name())));
}
}
@@ -20174,12 +20174,12 @@ class basic_json
JSON_CATCH (std::out_of_range&)
{
// create better exception explanation
JSON_THROW(out_of_range::create(403, "key '" + key + "' not found"));
JSON_THROW(out_of_range::create(403, diagnostics() + "key '" + key + "' not found"));
}
}
else
{
JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name())));
JSON_THROW(type_error::create(304, diagnostics() + "cannot use at() with " + std::string(type_name())));
}
}
@@ -20241,7 +20241,7 @@ class basic_json
#endif
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a numeric argument with " + std::string(type_name())));
}
/*!
@@ -20271,7 +20271,7 @@ class basic_json
return m_value.array->operator[](idx);
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a numeric argument with " + std::string(type_name())));
}
/*!
@@ -20323,7 +20323,7 @@ class basic_json
#endif
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a string argument with " + std::string(type_name())));
}
/*!
@@ -20365,7 +20365,7 @@ class basic_json
return m_value.object->find(key)->second;
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a string argument with " + std::string(type_name())));
}
/*!
@@ -20419,7 +20419,7 @@ class basic_json
#endif
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a string argument with " + std::string(type_name())));
}
/*!
@@ -20463,7 +20463,7 @@ class basic_json
return m_value.object->find(key)->second;
}
JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name())));
JSON_THROW(type_error::create(305, diagnostics() + "cannot use operator[] with a string argument with " + std::string(type_name())));
}
/*!
@@ -20535,7 +20535,7 @@ class basic_json
return default_value;
}
JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
JSON_THROW(type_error::create(306, diagnostics() + "cannot use value() with " + std::string(type_name())));
}
/*!
@@ -20608,7 +20608,7 @@ class basic_json
}
}
JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name())));
JSON_THROW(type_error::create(306, diagnostics() + "cannot use value() with " + std::string(type_name())));
}
/*!
@@ -20762,7 +20762,7 @@ class basic_json
// make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterator does not fit current value"));
}
IteratorType result = end();
@@ -20814,7 +20814,7 @@ class basic_json
}
default:
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
JSON_THROW(type_error::create(307, diagnostics() + "cannot use erase() with " + std::string(type_name())));
}
return result;
@@ -20875,7 +20875,7 @@ class basic_json
// make sure iterator fits the current value
if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
{
JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value"));
JSON_THROW(invalid_iterator::create(203, diagnostics() + "iterators do not fit current value"));
}
IteratorType result = end();
@@ -20892,7 +20892,7 @@ class basic_json
if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin()
|| !last.m_it.primitive_iterator.is_end()))
{
JSON_THROW(invalid_iterator::create(204, "iterators out of range"));
JSON_THROW(invalid_iterator::create(204, diagnostics() + "iterators out of range"));
}
if (is_string())
@@ -20930,7 +20930,7 @@ class basic_json
}
default:
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
JSON_THROW(type_error::create(307, diagnostics() + "cannot use erase() with " + std::string(type_name())));
}
return result;
@@ -20973,7 +20973,7 @@ class basic_json
return m_value.object->erase(key);
}
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
JSON_THROW(type_error::create(307, diagnostics() + "cannot use erase() with " + std::string(type_name())));
}
/*!
@@ -21007,14 +21007,14 @@ class basic_json
{
if (JSON_HEDLEY_UNLIKELY(idx >= size()))
{
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
JSON_THROW(out_of_range::create(401, diagnostics() + "array index " + std::to_string(idx) + " is out of range"));
}
m_value.array->erase(m_value.array->begin() + static_cast<difference_type>(idx));
}
else
{
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name())));
JSON_THROW(type_error::create(307, diagnostics() + "cannot use erase() with " + std::string(type_name())));
}
}
@@ -21959,7 +21959,7 @@ class basic_json
// push_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
JSON_THROW(type_error::create(308, diagnostics() + "cannot use push_back() with " + std::string(type_name())));
}
// transform null object into an array
@@ -21997,7 +21997,7 @@ class basic_json
// push_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
JSON_THROW(type_error::create(308, diagnostics() + "cannot use push_back() with " + std::string(type_name())));
}
// transform null object into an array
@@ -22050,7 +22050,7 @@ class basic_json
// push_back only works for null objects or objects
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
{
JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name())));
JSON_THROW(type_error::create(308, diagnostics() + "cannot use push_back() with " + std::string(type_name())));
}
// transform null object into an object
@@ -22158,7 +22158,7 @@ class basic_json
// emplace_back only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array())))
{
JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name())));
JSON_THROW(type_error::create(311, diagnostics() + "cannot use emplace_back() with " + std::string(type_name())));
}
// transform null object into an array
@@ -22220,7 +22220,7 @@ class basic_json
// emplace only works for null objects or arrays
if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object())))
{
JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name())));
JSON_THROW(type_error::create(311, diagnostics() + "cannot use emplace() with " + std::string(type_name())));
}
// transform null object into an object
@@ -22291,14 +22291,14 @@ class basic_json
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterator does not fit current value"));
}
// insert to array and return iterator
return insert_iterator(pos, val);
}
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
JSON_THROW(type_error::create(309, diagnostics() + "cannot use insert() with " + std::string(type_name())));
}
/*!
@@ -22342,14 +22342,14 @@ class basic_json
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterator does not fit current value"));
}
// insert to array and return iterator
return insert_iterator(pos, cnt, val);
}
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
JSON_THROW(type_error::create(309, diagnostics() + "cannot use insert() with " + std::string(type_name())));
}
/*!
@@ -22387,24 +22387,24 @@ class basic_json
// insert only works for arrays
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
JSON_THROW(type_error::create(309, diagnostics() + "cannot use insert() with " + std::string(type_name())));
}
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterator does not fit current value"));
}
// check if range iterators belong to the same JSON object
if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
JSON_THROW(invalid_iterator::create(210, diagnostics() + "iterators do not fit"));
}
if (JSON_HEDLEY_UNLIKELY(first.m_object == this))
{
JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container"));
JSON_THROW(invalid_iterator::create(211, diagnostics() + "passed iterators may not belong to container"));
}
// insert to array and return iterator
@@ -22440,13 +22440,13 @@ class basic_json
// insert only works for arrays
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
JSON_THROW(type_error::create(309, diagnostics() + "cannot use insert() with " + std::string(type_name())));
}
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterator does not fit current value"));
}
// insert to array and return iterator
@@ -22481,19 +22481,19 @@ class basic_json
// insert only works for objects
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name())));
JSON_THROW(type_error::create(309, diagnostics() + "cannot use insert() with " + std::string(type_name())));
}
// check if range iterators belong to the same JSON object
if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
JSON_THROW(invalid_iterator::create(210, diagnostics() + "iterators do not fit"));
}
// passed iterators must belong to objects
if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterators first and last must point to objects"));
}
m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator);
@@ -22530,11 +22530,11 @@ class basic_json
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
JSON_THROW(type_error::create(312, diagnostics() + "cannot use update() with " + std::string(type_name())));
}
if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name())));
JSON_THROW(type_error::create(312, diagnostics() + "cannot use update() with " + std::string(j.type_name())));
}
for (auto it = j.cbegin(); it != j.cend(); ++it)
@@ -22581,20 +22581,20 @@ class basic_json
if (JSON_HEDLEY_UNLIKELY(!is_object()))
{
JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name())));
JSON_THROW(type_error::create(312, diagnostics() + "cannot use update() with " + std::string(type_name())));
}
// check if range iterators belong to the same JSON object
if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
{
JSON_THROW(invalid_iterator::create(210, "iterators do not fit"));
JSON_THROW(invalid_iterator::create(210, diagnostics() + "iterators do not fit"));
}
// passed iterators must belong to objects
if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object()
|| !last.m_object->is_object()))
{
JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects"));
JSON_THROW(invalid_iterator::create(202, diagnostics() + "iterators first and last must point to objects"));
}
for (auto it = first; it != last; ++it)
@@ -22689,7 +22689,7 @@ class basic_json
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
JSON_THROW(type_error::create(310, diagnostics() + "cannot use swap() with " + std::string(type_name())));
}
}
@@ -22722,7 +22722,7 @@ class basic_json
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
JSON_THROW(type_error::create(310, diagnostics() + "cannot use swap() with " + std::string(type_name())));
}
}
@@ -22755,7 +22755,7 @@ class basic_json
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
JSON_THROW(type_error::create(310, diagnostics() + "cannot use swap() with " + std::string(type_name())));
}
}
@@ -22788,7 +22788,7 @@ class basic_json
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
JSON_THROW(type_error::create(310, diagnostics() + "cannot use swap() with " + std::string(type_name())));
}
}
@@ -22802,7 +22802,7 @@ class basic_json
}
else
{
JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name())));
JSON_THROW(type_error::create(310, diagnostics() + "cannot use swap() with " + std::string(type_name())));
}
}
@@ -24967,7 +24967,7 @@ class basic_json
};
// wrapper for "add" operation; add value at ptr
const auto operation_add = [&result](json_pointer & ptr, basic_json val)
const auto operation_add = [this, &result](json_pointer & ptr, basic_json val)
{
// adding to the root of the target document means replacing it
if (ptr.empty())
@@ -25011,7 +25011,7 @@ class basic_json
if (JSON_HEDLEY_UNLIKELY(idx > parent.size()))
{
// avoid undefined behavior
JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range"));
JSON_THROW(out_of_range::create(401, diagnostics() + "array index " + std::to_string(idx) + " is out of range"));
}
// default case: insert add offset
@@ -25027,7 +25027,7 @@ class basic_json
};
// wrapper for "remove" operation; remove value at ptr
const auto operation_remove = [&result](json_pointer & ptr)
const auto operation_remove = [this, &result](json_pointer & ptr)
{
// get reference to parent of JSON pointer ptr
const auto last_path = ptr.back();
@@ -25045,7 +25045,7 @@ class basic_json
}
else
{
JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found"));
JSON_THROW(out_of_range::create(403, diagnostics() + "key '" + last_path + "' not found"));
}
}
else if (parent.is_array())
@@ -25058,16 +25058,16 @@ class basic_json
// type check: top level value must be an array
if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
JSON_THROW(parse_error::create(104, 0, diagnostics() + "JSON patch must be an array of objects"));
}
// iterate and apply the operations
for (const auto& val : json_patch)
{
// wrapper to get a value for an operation
const auto get_value = [&val](const std::string & op,
const std::string & member,
bool string_type) -> basic_json &
const auto get_value = [this, &val](const std::string & op,
const std::string & member,
bool string_type) -> basic_json &
{
// find value
auto it = val.m_value.object->find(member);
@@ -25078,13 +25078,13 @@ class basic_json
// check if desired value is present
if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end()))
{
JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'"));
JSON_THROW(parse_error::create(105, 0, diagnostics() + error_msg + " must have member '" + member + "'"));
}
// check if result is of type string
if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
{
JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'"));
JSON_THROW(parse_error::create(105, 0, diagnostics() + error_msg + " must have string member '" + member + "'"));
}
// no error: return value
@@ -25094,7 +25094,7 @@ class basic_json
// type check: every element of the array must be an object
if (JSON_HEDLEY_UNLIKELY(!val.is_object()))
{
JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects"));
JSON_THROW(parse_error::create(104, 0, diagnostics() + "JSON patch must be an array of objects"));
}
// collect mandatory members
@@ -25172,7 +25172,7 @@ class basic_json
// throw an exception if test fails
if (JSON_HEDLEY_UNLIKELY(!success))
{
JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump()));
JSON_THROW(other_error::create(501, diagnostics() + "unsuccessful: " + val.dump()));
}
break;
@@ -25182,7 +25182,7 @@ class basic_json
{
// op must be "add", "remove", "replace", "move", "copy", or
// "test"
JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid"));
JSON_THROW(parse_error::create(105, 0, diagnostics() + "operation value '" + op + "' is invalid"));
}
}
}