mirror of
https://github.com/nlohmann/json.git
synced 2025-11-24 03:44:06 +08:00
Add operator<<(json_pointer) (#3601)
* Add operator<< for json_pointer * Deprecate json_pointer::operator string_t() * Update documentation * Move operator<<(basic_json) example * Add example * Add mkdocs-redirects * Move operator<< and operator>> doc pages out of basic_json/ * Rename JSON pointer operator_string to operator_string_t * Add unit test
This commit is contained in:
committed by
GitHub
parent
7777300442
commit
e3095f636f
@@ -12,6 +12,8 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
using nlohmann::json;
|
||||
|
||||
#include <sstream>
|
||||
|
||||
TEST_CASE("JSON pointers")
|
||||
{
|
||||
SECTION("errors")
|
||||
@@ -475,12 +477,16 @@ TEST_CASE("JSON pointers")
|
||||
|
||||
SECTION("string representation")
|
||||
{
|
||||
for (const auto* ptr :
|
||||
for (const auto* ptr_str :
|
||||
{"", "/foo", "/foo/0", "/", "/a~1b", "/c%d", "/e^f", "/g|h", "/i\\j", "/k\"l", "/ ", "/m~0n"
|
||||
})
|
||||
{
|
||||
CHECK(json::json_pointer(ptr).to_string() == ptr);
|
||||
CHECK(std::string(json::json_pointer(ptr)) == ptr);
|
||||
json::json_pointer ptr(ptr_str);
|
||||
std::stringstream ss;
|
||||
ss << ptr;
|
||||
CHECK(ptr.to_string() == ptr_str);
|
||||
CHECK(std::string(ptr) == ptr_str);
|
||||
CHECK(ss.str() == ptr_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user