mirror of https://github.com/nlohmann/json.git
commit
cb053bceb1
|
@ -34,7 +34,8 @@ SOFTWARE.
|
||||||
|
|
||||||
#define JSON_TESTS_PRIVATE
|
#define JSON_TESTS_PRIVATE
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
using nlohmann::json;
|
using json = nlohmann::json;
|
||||||
|
using ordered_json = nlohmann::ordered_json;
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -659,6 +660,25 @@ TEST_CASE("regression tests 2")
|
||||||
{
|
{
|
||||||
static_assert(std::is_copy_assignable<nlohmann::ordered_json>::value, "");
|
static_assert(std::is_copy_assignable<nlohmann::ordered_json>::value, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SECTION("issue #2958 - Inserting in unordered json using a pointer retains the leading slash")
|
||||||
|
{
|
||||||
|
std::string p = "/root";
|
||||||
|
|
||||||
|
// matching types
|
||||||
|
json test1;
|
||||||
|
test1[json::json_pointer(p)] = json::object();
|
||||||
|
CHECK(test1.dump() == "{\"root\":{}}");
|
||||||
|
|
||||||
|
ordered_json test2;
|
||||||
|
test2[ordered_json::json_pointer(p)] = json::object();
|
||||||
|
CHECK(test2.dump() == "{\"root\":{}}");
|
||||||
|
|
||||||
|
// mixed type - the JSON Pointer is implicitly converted into a string "/root"
|
||||||
|
ordered_json test3;
|
||||||
|
test3[json::json_pointer(p)] = json::object();
|
||||||
|
CHECK(test3.dump() == "{\"/root\":{}}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
||||||
|
|
Loading…
Reference in New Issue