1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-13 20:21:48 +03:00

added test cases

This commit is contained in:
Niels
2016-04-30 00:03:47 +02:00
parent 82f5332cf4
commit 1d3b4dd158
7 changed files with 160 additions and 7 deletions

View File

@ -8818,6 +8818,10 @@ basic_json_parser_63:
/*!
@brief JSON Pointer
A JSON pointer defines a string syntax for identifying a specific value
within a JSON document. It can be used with functions `at` and
`operator[]`. Furthermore, JSON pointers are the base for JSON patches.
@sa [RFC 6901](https://tools.ietf.org/html/rfc6901)
@since version 2.0.0
@ -8854,10 +8858,37 @@ basic_json_parser_63:
: reference_tokens(split(s))
{}
/// test for inequality
bool operator!=(const json_pointer& rhs) const
/*!
@brief return a string representation of the JSON pointer
@invariant For each JSON pointer `ptr`, it holds:
@code {.cpp}
ptr == json_pointer(ptr.to_string());
@endcode
@return a string representation of the JSON pointer
@liveexample{The example shows the result of `to_string`.,
json_pointer__to_string}
@since version 2.0.0
*/
std::string to_string() const noexcept
{
return reference_tokens != rhs.reference_tokens;
std::string result;
for (const auto& reference_token : reference_tokens)
{
result += "/" + escape(reference_token);
}
return result;
}
/// @copydoc to_string()
operator std::string() const
{
return to_string();
}
private: