✨ proposal for #428
This implementation forwards the iterators to std::map::insert.
This commit is contained in:
parent
90273e930c
commit
97a25de938
5 changed files with 150 additions and 1 deletions
|
@ -594,7 +594,7 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("range")
|
||||
SECTION("range for array")
|
||||
{
|
||||
json j_other_array = {"first", "second"};
|
||||
|
||||
|
@ -631,6 +631,40 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("range for object")
|
||||
{
|
||||
json j_object1 = {{"one", "eins"}, {"two", "zwei"}};
|
||||
json j_object2 = {{"eleven", "elf"}, {"seventeen", "siebzehn"}};
|
||||
|
||||
SECTION("proper usage")
|
||||
{
|
||||
j_object1.insert(j_object2.begin(), j_object2.end());
|
||||
CHECK(j_object1.size() == 4);
|
||||
}
|
||||
|
||||
SECTION("empty range")
|
||||
{
|
||||
j_object1.insert(j_object2.begin(), j_object2.begin());
|
||||
CHECK(j_object1.size() == 2);
|
||||
}
|
||||
|
||||
SECTION("invalid iterators")
|
||||
{
|
||||
json j_other_array2 = {"first", "second"};
|
||||
|
||||
CHECK_THROWS_AS(j_array.insert(j_object2.begin(), j_object2.end()), json::type_error);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_object1.begin(), j_object2.end()), json::invalid_iterator);
|
||||
CHECK_THROWS_AS(j_object1.insert(j_array.begin(), j_array.end()), json::invalid_iterator);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.insert(j_object2.begin(), j_object2.end()),
|
||||
"[json.exception.type_error.309] cannot use insert() with array");
|
||||
CHECK_THROWS_WITH(j_object1.insert(j_object1.begin(), j_object2.end()),
|
||||
"[json.exception.invalid_iterator.210] iterators do not fit");
|
||||
CHECK_THROWS_WITH(j_object1.insert(j_array.begin(), j_array.end()),
|
||||
"[json.exception.invalid_iterator.202] iterators first and last must point to objects");
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("initializer list at position")
|
||||
{
|
||||
SECTION("insert before begin()")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue