mirror of
https://github.com/nlohmann/json.git
synced 2024-11-28 09:09:02 +08:00
Test initialization with dup keys
This commit is contained in:
parent
08963d6826
commit
cf18ba2394
@ -58,4 +58,15 @@ TEST_CASE("ordered_json")
|
||||
|
||||
CHECK(j.dump() == "{\"element2\":2,\"element3\":3}");
|
||||
CHECK(oj.dump() == "{\"element3\":3,\"element2\":2}");
|
||||
|
||||
// There are no dup keys cause constructor calls emplace...
|
||||
json multi {{"z", 1}, {"m", 2}, {"m", 3}, {"y", 4}, {"m", 5}};
|
||||
CHECK(multi.size() == 3);
|
||||
CHECK(multi.dump() == "{\"m\":2,\"y\":4,\"z\":1}");
|
||||
|
||||
ordered_json multi_ordered {{"z", 1}, {"m", 2}, {"m", 3}, {"y", 4}, {"m", 5}};
|
||||
CHECK(multi_ordered.size() == 3);
|
||||
CHECK(multi_ordered.dump() == "{\"z\":1,\"m\":2,\"y\":4}");
|
||||
CHECK(multi_ordered.erase("m") == 1);
|
||||
CHECK(multi_ordered.dump() == "{\"z\":1,\"y\":4}");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user