mirror of
https://github.com/nlohmann/json.git
synced 2026-10-28 00:35:43 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84c5421644 |
@@ -1504,13 +1504,16 @@ TEST_CASE("regression tests 1")
|
|||||||
// a copied fifo_map restarts its timestamps, so a new key "k" gets
|
// a copied fifo_map restarts its timestamps, so a new key "k" gets
|
||||||
// the timestamp of "x": the lookup does not find "k", but emplace()
|
// the timestamp of "x": the lookup does not find "k", but emplace()
|
||||||
// finds "x" and inserts nothing; the pointer then continues with the
|
// finds "x" and inserts nothing; the pointer then continues with the
|
||||||
// member of "x", as basic_json::operator[] does
|
// member of "x", as basic_json::operator[] does. The object_t is
|
||||||
|
// copied explicitly: copying the my_json would build the object
|
||||||
|
// member by member (with fresh timestamps) when built with
|
||||||
|
// JSON_NO_THREAD_LOCAL.
|
||||||
const my_json orig = my_json::parse(R"({"x":1})");
|
const my_json orig = my_json::parse(R"({"x":1})");
|
||||||
const std::array<const char*, 3> pointers = {{"/k/0", "/k/a/b", "/k/-"}};
|
const std::array<const char*, 3> pointers = {{"/k/0", "/k/a/b", "/k/-"}};
|
||||||
for (const char* pointer : pointers)
|
for (const char* pointer : pointers)
|
||||||
{
|
{
|
||||||
CAPTURE(pointer)
|
CAPTURE(pointer)
|
||||||
my_json j = orig;
|
my_json j(orig.get_ref<const my_json::object_t&>());
|
||||||
CHECK_THROWS_AS(j[my_json::json_pointer(pointer)], my_json::out_of_range&);
|
CHECK_THROWS_AS(j[my_json::json_pointer(pointer)], my_json::out_of_range&);
|
||||||
CHECK(j.dump() == R"({"x":1})");
|
CHECK(j.dump() == R"({"x":1})");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user