Add unit test

This commit is contained in:
Florian Albrechtskirchinger 2022-07-24 09:46:23 +02:00
parent 3dd24e88b9
commit e6d7cfe3fa
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D

View File

@ -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);
}
}