1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

🚨 fix warnings

This commit is contained in:
Niels Lohmann
2021-01-10 13:39:36 +01:00
parent e160749003
commit a83404525e
4 changed files with 62 additions and 86 deletions

View File

@ -32,7 +32,7 @@ number_float), because the library distinguishes these three types for numbers:
@ref basic_json::number_float_t is used for floating-point numbers or to @ref basic_json::number_float_t is used for floating-point numbers or to
approximate integers which do not fit in the limits of their respective type. approximate integers which do not fit in the limits of their respective type.
@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON @sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON
value with the default value for a given type value with the default value for a given type
@since version 1.0.0 @since version 1.0.0

View File

@ -5746,7 +5746,7 @@ class basic_json
iterator result = insert_iterator(pos, cnt, val); iterator result = insert_iterator(pos, cnt, val);
for (size_type i = 0; i < cnt; ++i) for (size_type i = 0; i < cnt; ++i)
{ {
(result + i)->m_parent = this; (result + static_cast<typename iterator::difference_type>(i))->m_parent = this;
} }
return result; return result;
#else #else
@ -5815,7 +5815,7 @@ class basic_json
// insert to array and return iterator // insert to array and return iterator
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
for (std::size_t i = 0; i < std::distance(first, last); ++i) for (typename iterator::difference_type i = 0; i < std::distance(first, last); ++i)
{ {
(result + i)->m_parent = this; (result + i)->m_parent = this;
} }
@ -5869,7 +5869,7 @@ class basic_json
iterator result = insert_iterator(pos, ilist.begin(), ilist.end()); iterator result = insert_iterator(pos, ilist.begin(), ilist.end());
for (std::size_t i = 0; i < size; ++i) for (std::size_t i = 0; i < size; ++i)
{ {
(result + i)->m_parent = this; (result + static_cast<typename iterator::difference_type>(i))->m_parent = this;
} }
return result; return result;
#else #else
@ -8391,7 +8391,7 @@ class basic_json
}; };
// wrapper for "add" operation; add value at ptr // wrapper for "add" operation; add value at ptr
const auto operation_add = [this, &result](json_pointer & ptr, basic_json val) const auto operation_add = [&result](json_pointer & ptr, basic_json val)
{ {
// adding to the root of the target document means replacing it // adding to the root of the target document means replacing it
if (ptr.empty()) if (ptr.empty())
@ -8489,9 +8489,9 @@ class basic_json
for (const auto& val : json_patch) for (const auto& val : json_patch)
{ {
// wrapper to get a value for an operation // wrapper to get a value for an operation
const auto get_value = [this, &val](const std::string & op, const auto get_value = [&val](const std::string & op,
const std::string & member, const std::string & member,
bool string_type) -> basic_json & bool string_type) -> basic_json &
{ {
// find value // find value
auto it = val.m_value.object->find(member); auto it = val.m_value.object->find(member);

View File

@ -113,7 +113,7 @@ number_float), because the library distinguishes these three types for numbers:
@ref basic_json::number_float_t is used for floating-point numbers or to @ref basic_json::number_float_t is used for floating-point numbers or to
approximate integers which do not fit in the limits of their respective type. approximate integers which do not fit in the limits of their respective type.
@sa @ref basic_json::basic_json(const value_t value_type) -- create a JSON @sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON
value with the default value for a given type value with the default value for a given type
@since version 1.0.0 @since version 1.0.0
@ -22490,7 +22490,7 @@ class basic_json
iterator result = insert_iterator(pos, cnt, val); iterator result = insert_iterator(pos, cnt, val);
for (size_type i = 0; i < cnt; ++i) for (size_type i = 0; i < cnt; ++i)
{ {
(result + i)->m_parent = this; (result + static_cast<typename iterator::difference_type>(i))->m_parent = this;
} }
return result; return result;
#else #else
@ -22559,7 +22559,7 @@ class basic_json
// insert to array and return iterator // insert to array and return iterator
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator); iterator result = insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator);
for (std::size_t i = 0; i < std::distance(first, last); ++i) for (typename iterator::difference_type i = 0; i < std::distance(first, last); ++i)
{ {
(result + i)->m_parent = this; (result + i)->m_parent = this;
} }
@ -22613,7 +22613,7 @@ class basic_json
iterator result = insert_iterator(pos, ilist.begin(), ilist.end()); iterator result = insert_iterator(pos, ilist.begin(), ilist.end());
for (std::size_t i = 0; i < size; ++i) for (std::size_t i = 0; i < size; ++i)
{ {
(result + i)->m_parent = this; (result + static_cast<typename iterator::difference_type>(i))->m_parent = this;
} }
return result; return result;
#else #else
@ -25135,7 +25135,7 @@ class basic_json
}; };
// wrapper for "add" operation; add value at ptr // wrapper for "add" operation; add value at ptr
const auto operation_add = [this, &result](json_pointer & ptr, basic_json val) const auto operation_add = [&result](json_pointer & ptr, basic_json val)
{ {
// adding to the root of the target document means replacing it // adding to the root of the target document means replacing it
if (ptr.empty()) if (ptr.empty())
@ -25233,9 +25233,9 @@ class basic_json
for (const auto& val : json_patch) for (const auto& val : json_patch)
{ {
// wrapper to get a value for an operation // wrapper to get a value for an operation
const auto get_value = [this, &val](const std::string & op, const auto get_value = [&val](const std::string & op,
const std::string & member, const std::string & member,
bool string_type) -> basic_json & bool string_type) -> basic_json &
{ {
// find value // find value
auto it = val.m_value.object->find(member); auto it = val.m_value.object->find(member);

View File

@ -691,11 +691,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {"op", "add", "path", "", "value", 1}; json patch = {"op", "add", "path", "", "value", 1};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: (/0) JSON patch must be an array of objects");
#else #else
"[json.exception.parse_error.104] parse error: JSON patch must be an array of objects"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.104] parse error: JSON patch must be an array of objects");
#endif #endif
} }
@ -704,11 +703,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"foo", "bar"}}}; json patch = {{{"foo", "bar"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation must have member 'op'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have member 'op'");
#else #else
"[json.exception.parse_error.105] parse error: operation must have member 'op'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have member 'op'");
#endif #endif
} }
@ -717,11 +715,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", 1}}}; json patch = {{{"op", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation must have string member 'op'");
#else #else
"[json.exception.parse_error.105] parse error: operation must have string member 'op'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation must have string member 'op'");
#endif #endif
} }
@ -730,11 +727,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "foo"}, {"path", ""}}}; json patch = {{{"op", "foo"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation value 'foo' is invalid"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation value 'foo' is invalid");
#else #else
"[json.exception.parse_error.105] parse error: operation value 'foo' is invalid"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation value 'foo' is invalid");
#endif #endif
} }
} }
@ -746,11 +742,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "add"}}}; json patch = {{{"op", "add"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'path'");
#endif #endif
} }
@ -759,11 +754,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "add"}, {"path", 1}}}; json patch = {{{"op", "add"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have string member 'path'");
#endif #endif
} }
@ -772,11 +766,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "add"}, {"path", ""}}}; json patch = {{{"op", "add"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'add' must have member 'value'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'add' must have member 'value'");
#endif #endif
} }
@ -797,11 +790,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "remove"}}}; json patch = {{{"op", "remove"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have member 'path'");
#endif #endif
} }
@ -810,11 +802,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "remove"}, {"path", 1}}}; json patch = {{{"op", "remove"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'remove' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'remove' must have string member 'path'");
#endif #endif
} }
@ -853,11 +844,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "replace"}}}; json patch = {{{"op", "replace"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'path'");
#endif #endif
} }
@ -866,11 +856,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "replace"}, {"path", 1}}}; json patch = {{{"op", "replace"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have string member 'path'");
#endif #endif
} }
@ -879,11 +868,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "replace"}, {"path", ""}}}; json patch = {{{"op", "replace"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'replace' must have member 'value'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'replace' must have member 'value'");
#endif #endif
} }
@ -913,13 +901,11 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "move"}}}; json patch = {{{"op", "move"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'" CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'" CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'path'");
#endif #endif
);
} }
SECTION("non-string 'path'") SECTION("non-string 'path'")
@ -927,11 +913,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "move"}, {"path", 1}}}; json patch = {{{"op", "move"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'path'");
#endif #endif
} }
@ -940,11 +925,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "move"}, {"path", ""}}}; json patch = {{{"op", "move"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have member 'from'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have member 'from'");
#endif #endif
} }
@ -953,11 +937,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}}; json patch = {{{"op", "move"}, {"path", ""}, {"from", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'move' must have string member 'from'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'move' must have string member 'from'");
#endif #endif
} }
@ -987,11 +970,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "copy"}}}; json patch = {{{"op", "copy"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'path'");
#endif #endif
} }
@ -1000,11 +982,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "copy"}, {"path", 1}}}; json patch = {{{"op", "copy"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'path'");
#endif #endif
} }
@ -1013,11 +994,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "copy"}, {"path", ""}}}; json patch = {{{"op", "copy"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have member 'from'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have member 'from'");
#endif #endif
} }
@ -1026,11 +1006,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}}; json patch = {{{"op", "copy"}, {"path", ""}, {"from", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'copy' must have string member 'from'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'copy' must have string member 'from'");
#endif #endif
} }
@ -1060,11 +1039,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "test"}}}; json patch = {{{"op", "test"}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'path'");
#endif #endif
} }
@ -1073,11 +1051,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "test"}, {"path", 1}}}; json patch = {{{"op", "test"}, {"path", 1}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have string member 'path'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have string member 'path'");
#endif #endif
} }
@ -1086,11 +1063,10 @@ TEST_CASE("JSON patch")
json j; json j;
json patch = {{{"op", "test"}, {"path", ""}}}; json patch = {{{"op", "test"}, {"path", ""}}};
CHECK_THROWS_AS(j.patch(patch), json::parse_error&); CHECK_THROWS_AS(j.patch(patch), json::parse_error&);
CHECK_THROWS_WITH(j.patch(patch),
#if JSON_DIAGNOSTICS #if JSON_DIAGNOSTICS
"[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: (/0) operation 'test' must have member 'value'");
#else #else
"[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'"); CHECK_THROWS_WITH(j.patch(patch), "[json.exception.parse_error.105] parse error: operation 'test' must have member 'value'");
#endif #endif
} }
} }