✅ added test cases for update #661
This commit is contained in:
parent
d1e13d5128
commit
d2c3592908
2 changed files with 97 additions and 4 deletions
|
|
@ -489,7 +489,7 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("insert")
|
||||
SECTION("insert()")
|
||||
{
|
||||
json j_array = {1, 2, 3, 4};
|
||||
json j_value = 5;
|
||||
|
|
@ -740,6 +740,53 @@ TEST_CASE("modifiers")
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("update()")
|
||||
{
|
||||
json j_object1 = {{"one", "eins"}, {"two", "zwei"}};
|
||||
json j_object2 = {{"three", "drei"}, {"two", "zwo"}};
|
||||
json j_array = {1, 2, 3, 4};
|
||||
|
||||
SECTION("const reference")
|
||||
{
|
||||
SECTION("proper usage")
|
||||
{
|
||||
j_object1.update(j_object2);
|
||||
CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwo"}, {"three", "drei"}}));
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("iterator range")
|
||||
{
|
||||
SECTION("proper usage")
|
||||
{
|
||||
j_object1.update(j_object2.begin(), j_object2.end());
|
||||
CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwo"}, {"three", "drei"}}));
|
||||
}
|
||||
|
||||
SECTION("empty range")
|
||||
{
|
||||
j_object1.update(j_object2.begin(), j_object2.begin());
|
||||
CHECK(j_object1 == json({{"one", "eins"}, {"two", "zwei"}}));
|
||||
}
|
||||
|
||||
SECTION("invalid iterators")
|
||||
{
|
||||
json j_other_array2 = {"first", "second"};
|
||||
|
||||
CHECK_THROWS_AS(j_array.update(j_object2.begin(), j_object2.end()), json::type_error&);
|
||||
CHECK_THROWS_AS(j_object1.update(j_object1.begin(), j_object2.end()), json::invalid_iterator&);
|
||||
CHECK_THROWS_AS(j_object1.update(j_array.begin(), j_array.end()), json::invalid_iterator&);
|
||||
|
||||
CHECK_THROWS_WITH(j_array.update(j_object2.begin(), j_object2.end()),
|
||||
"[json.exception.type_error.305] cannot use merge() with array");
|
||||
CHECK_THROWS_WITH(j_object1.update(j_object1.begin(), j_object2.end()),
|
||||
"[json.exception.invalid_iterator.210] iterators do not fit");
|
||||
CHECK_THROWS_WITH(j_object1.update(j_array.begin(), j_array.end()),
|
||||
"[json.exception.invalid_iterator.202] iterators first and last must point to objects");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("swap()")
|
||||
{
|
||||
SECTION("json")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue