Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6be3f82b25 | ||
|
|
0eabcc51eb |
No files matched your search
@@ -222,7 +222,8 @@ class exception : public std::exception
|
||||
template<typename BasicJsonType>
|
||||
static std::string get_byte_positions(const BasicJsonType* leaf_element)
|
||||
{
|
||||
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
|
||||
// a value-initialized iterator has no value (invalid_iterator.212)
|
||||
if (leaf_element != nullptr && leaf_element->start_pos() != std::string::npos && leaf_element->end_pos() != std::string::npos)
|
||||
{
|
||||
return concat("(bytes ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()), ") ");
|
||||
}
|
||||
|
||||
Generated
+2
-1
@@ -5719,7 +5719,8 @@ class exception : public std::exception
|
||||
template<typename BasicJsonType>
|
||||
static std::string get_byte_positions(const BasicJsonType* leaf_element)
|
||||
{
|
||||
if ((leaf_element->start_pos() != std::string::npos) && (leaf_element->end_pos() != std::string::npos))
|
||||
// a value-initialized iterator has no value (invalid_iterator.212)
|
||||
if (leaf_element != nullptr && leaf_element->start_pos() != std::string::npos && leaf_element->end_pos() != std::string::npos)
|
||||
{
|
||||
return concat("(bytes ", std::to_string(leaf_element->start_pos()), "-", std::to_string(leaf_element->end_pos()), ") ");
|
||||
}
|
||||
|
||||
@@ -243,3 +243,14 @@ TEST_CASE("values read from a binary format have no positions")
|
||||
check_no_positions(j);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("comparing a value-initialized iterator throws invalid_iterator.212")
|
||||
{
|
||||
// such an iterator has no value to take the byte positions from; the
|
||||
// comparison used to dereference the null pointer instead of throwing
|
||||
json j = {1, 2};
|
||||
const json::iterator it{};
|
||||
CHECK_THROWS_WITH_AS(it == j.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator);
|
||||
CHECK_THROWS_WITH_AS(it < j.begin(), "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator);
|
||||
CHECK_THROWS_WITH_AS(j.begin() == it, "[json.exception.invalid_iterator.212] cannot compare iterators of different containers", json::invalid_iterator);
|
||||
}
|
||||
Reference in new issue
Block a user