1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-21 04:22:05 +03:00

🔨 added user-defined exceptions 201-202

Started implementing exceptions for invalid iterators.
This commit is contained in:
Niels Lohmann
2017-03-03 13:19:45 +01:00
parent e291c6c3d2
commit 9381f6c4da
6 changed files with 80 additions and 72 deletions

View File

@ -662,22 +662,22 @@ TEST_CASE("modifiers")
// pass iterator to a different array
json j_another_array = {1, 2};
json j_yet_another_array = {"first", "second"};
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), std::domain_error);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), std::domain_error);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), std::domain_error);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(),
j_yet_another_array.end()), std::domain_error);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), std::domain_error);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10), json::invalid_iterator);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_value), json::invalid_iterator);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), 10, 11), json::invalid_iterator);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()), json::invalid_iterator);
CHECK_THROWS_AS(j_array.insert(j_another_array.end(), {1, 2, 3, 4}), json::invalid_iterator);
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), 10), "iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), 10),
"[json.exception.invalid_iterator.202] iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), j_value),
"iterator does not fit current value");
"[json.exception.invalid_iterator.202] iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), 10, 11),
"iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), j_yet_another_array.begin(),
j_yet_another_array.end()), "iterator does not fit current value");
"[json.exception.invalid_iterator.202] iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), j_yet_another_array.begin(), j_yet_another_array.end()),
"[json.exception.invalid_iterator.202] iterator does not fit current value");
CHECK_THROWS_WITH(j_array.insert(j_another_array.end(), {1, 2, 3, 4}),
"iterator does not fit current value");
"[json.exception.invalid_iterator.202] iterator does not fit current value");
}
SECTION("non-array type")