🔨 added user-defined exceptions 205-206
This commit is contained in:
		
							parent
							
								
									875b2da95d
								
							
						
					
					
						commit
						a4274d7766
					
				
					 6 changed files with 102 additions and 98 deletions
				
			
		
							
								
								
									
										15
									
								
								src/json.hpp
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								src/json.hpp
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2422,8 +2422,8 @@ class basic_json
 | 
			
		|||
    boolean, or string) where an out of range error can be detected easily;
 | 
			
		||||
    example: `"iterators out of range"`
 | 
			
		||||
    @throw std::bad_alloc if allocation for object, array, or string fails
 | 
			
		||||
    @throw std::domain_error if called with a null value; example: `"cannot
 | 
			
		||||
    use construct with iterators from null"`
 | 
			
		||||
    @throw invalid_iterator.206 if called with a null value; example: `"cannot
 | 
			
		||||
    construct with iterators from null"`
 | 
			
		||||
 | 
			
		||||
    @complexity Linear in distance between @a first and @a last.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2519,7 +2519,8 @@ class basic_json
 | 
			
		|||
 | 
			
		||||
            default:
 | 
			
		||||
            {
 | 
			
		||||
                JSON_THROW(std::domain_error("cannot use construct with iterators from " + first.m_object->type_name()));
 | 
			
		||||
                JSON_THROW(invalid_iterator(206, "cannot construct with iterators from " +
 | 
			
		||||
                                            first.m_object->type_name()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4402,7 +4403,7 @@ class basic_json
 | 
			
		|||
    @throw invalid_iterator.202 if called on an iterator which does not belong
 | 
			
		||||
    to the current JSON value; example: `"iterator does not fit current
 | 
			
		||||
    value"`
 | 
			
		||||
    @throw std::out_of_range if called on a primitive type with invalid
 | 
			
		||||
    @throw invalid_iterator.205 if called on a primitive type with invalid
 | 
			
		||||
    iterator (i.e., any iterator which is not `begin()`); example: `"iterator
 | 
			
		||||
    out of range"`
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4448,7 +4449,7 @@ class basic_json
 | 
			
		|||
            {
 | 
			
		||||
                if (not pos.m_it.primitive_iterator.is_begin())
 | 
			
		||||
                {
 | 
			
		||||
                    JSON_THROW(std::out_of_range("iterator out of range"));
 | 
			
		||||
                    JSON_THROW(invalid_iterator(205, "iterator out of range"));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (is_string())
 | 
			
		||||
| 
						 | 
				
			
			@ -9625,7 +9626,7 @@ class basic_json
 | 
			
		|||
            {
 | 
			
		||||
                case basic_json::value_t::object:
 | 
			
		||||
                {
 | 
			
		||||
                    JSON_THROW(std::domain_error("cannot use operator[] for object iterators"));
 | 
			
		||||
                    JSON_THROW(invalid_iterator(208, "cannot use operator[] for object iterators"));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                case basic_json::value_t::array:
 | 
			
		||||
| 
						 | 
				
			
			@ -9663,7 +9664,7 @@ class basic_json
 | 
			
		|||
                return m_it.object_iterator->first;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            JSON_THROW(std::domain_error("cannot use key() for non-object iterators"));
 | 
			
		||||
            JSON_THROW(invalid_iterator(207, "cannot use key() for non-object iterators"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*!
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2422,8 +2422,8 @@ class basic_json
 | 
			
		|||
    boolean, or string) where an out of range error can be detected easily;
 | 
			
		||||
    example: `"iterators out of range"`
 | 
			
		||||
    @throw std::bad_alloc if allocation for object, array, or string fails
 | 
			
		||||
    @throw std::domain_error if called with a null value; example: `"cannot
 | 
			
		||||
    use construct with iterators from null"`
 | 
			
		||||
    @throw invalid_iterator.206 if called with a null value; example: `"cannot
 | 
			
		||||
    construct with iterators from null"`
 | 
			
		||||
 | 
			
		||||
    @complexity Linear in distance between @a first and @a last.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -2519,7 +2519,8 @@ class basic_json
 | 
			
		|||
 | 
			
		||||
            default:
 | 
			
		||||
            {
 | 
			
		||||
                JSON_THROW(std::domain_error("cannot use construct with iterators from " + first.m_object->type_name()));
 | 
			
		||||
                JSON_THROW(invalid_iterator(206, "cannot construct with iterators from " +
 | 
			
		||||
                                            first.m_object->type_name()));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4402,7 +4403,7 @@ class basic_json
 | 
			
		|||
    @throw invalid_iterator.202 if called on an iterator which does not belong
 | 
			
		||||
    to the current JSON value; example: `"iterator does not fit current
 | 
			
		||||
    value"`
 | 
			
		||||
    @throw std::out_of_range if called on a primitive type with invalid
 | 
			
		||||
    @throw invalid_iterator.205 if called on a primitive type with invalid
 | 
			
		||||
    iterator (i.e., any iterator which is not `begin()`); example: `"iterator
 | 
			
		||||
    out of range"`
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4448,7 +4449,7 @@ class basic_json
 | 
			
		|||
            {
 | 
			
		||||
                if (not pos.m_it.primitive_iterator.is_begin())
 | 
			
		||||
                {
 | 
			
		||||
                    JSON_THROW(std::out_of_range("iterator out of range"));
 | 
			
		||||
                    JSON_THROW(invalid_iterator(205, "iterator out of range"));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (is_string())
 | 
			
		||||
| 
						 | 
				
			
			@ -9625,7 +9626,7 @@ class basic_json
 | 
			
		|||
            {
 | 
			
		||||
                case basic_json::value_t::object:
 | 
			
		||||
                {
 | 
			
		||||
                    JSON_THROW(std::domain_error("cannot use operator[] for object iterators"));
 | 
			
		||||
                    JSON_THROW(invalid_iterator(208, "cannot use operator[] for object iterators"));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                case basic_json::value_t::array:
 | 
			
		||||
| 
						 | 
				
			
			@ -9663,7 +9664,7 @@ class basic_json
 | 
			
		|||
                return m_it.object_iterator->first;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            JSON_THROW(std::domain_error("cannot use key() for non-object iterators"));
 | 
			
		||||
            JSON_THROW(invalid_iterator(207, "cannot use key() for non-object iterators"));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /*!
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1106,13 +1106,15 @@ TEST_CASE("constructors")
 | 
			
		|||
                {
 | 
			
		||||
                    {
 | 
			
		||||
                        json j;
 | 
			
		||||
                        CHECK_THROWS_AS(json(j.begin(), j.end()), std::domain_error);
 | 
			
		||||
                        CHECK_THROWS_WITH(json(j.begin(), j.end()), "cannot use construct with iterators from null");
 | 
			
		||||
                        CHECK_THROWS_AS(json(j.begin(), j.end()), json::invalid_iterator);
 | 
			
		||||
                        CHECK_THROWS_WITH(json(j.begin(), j.end()),
 | 
			
		||||
                                          "[json.exception.invalid_iterator.206] cannot construct with iterators from null");
 | 
			
		||||
                    }
 | 
			
		||||
                    {
 | 
			
		||||
                        json j;
 | 
			
		||||
                        CHECK_THROWS_AS(json(j.cbegin(), j.cend()), std::domain_error);
 | 
			
		||||
                        CHECK_THROWS_WITH(json(j.cbegin(), j.cend()), "cannot use construct with iterators from null");
 | 
			
		||||
                        CHECK_THROWS_AS(json(j.cbegin(), j.cend()), json::invalid_iterator);
 | 
			
		||||
                        CHECK_THROWS_WITH(json(j.cbegin(), j.cend()),
 | 
			
		||||
                                          "[json.exception.invalid_iterator.206] cannot construct with iterators from null");
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -689,13 +689,13 @@ TEST_CASE("element access 1")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    json j = "foo";
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    json j = "bar";
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -703,13 +703,13 @@ TEST_CASE("element access 1")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    json j = false;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    json j = true;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -717,13 +717,13 @@ TEST_CASE("element access 1")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 17;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 17;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -731,13 +731,13 @@ TEST_CASE("element access 1")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 17u;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 17u;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -745,13 +745,13 @@ TEST_CASE("element access 1")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 23.42;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.end()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.end()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    json j = 23.42;
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), std::out_of_range);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "iterator out of range");
 | 
			
		||||
                    CHECK_THROWS_AS(j.erase(j.cend()), json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(j.erase(j.cend()), "[json.exception.invalid_iterator.205] iterator out of range");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -229,22 +229,22 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json(true));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json(true));
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -433,22 +433,22 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json("hello world"));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json("hello world"));
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -630,11 +630,11 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json(1));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json(1));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1007,22 +1007,22 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json(23));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json(23));
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1211,22 +1211,22 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json(23));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json(23));
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1415,22 +1415,22 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(it.value() == json(23.42));
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK(cit.value() == json(23.42));
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1489,24 +1489,24 @@ TEST_CASE("iterators 1")
 | 
			
		|||
            {
 | 
			
		||||
                auto it = j.begin();
 | 
			
		||||
                auto cit = j_const.cbegin();
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(it.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(it.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(cit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(cit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(it.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(it.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(cit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(cit.value(), "cannot get value");
 | 
			
		||||
 | 
			
		||||
                auto rit = j.rend();
 | 
			
		||||
                auto crit = j.crend();
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(rit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(rit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), std::domain_error);
 | 
			
		||||
                CHECK_THROWS_AS(crit.key(), json::invalid_iterator);
 | 
			
		||||
                CHECK_THROWS_AS(crit.value(), std::out_of_range);
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(rit.value(), "cannot get value");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.key(), "[json.exception.invalid_iterator.207] cannot use key() for non-object iterators");
 | 
			
		||||
                CHECK_THROWS_WITH(crit.value(), "cannot get value");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -380,17 +380,17 @@ TEST_CASE("iterators 2")
 | 
			
		|||
            {
 | 
			
		||||
                {
 | 
			
		||||
                    auto it = j_object.begin();
 | 
			
		||||
                    CHECK_THROWS_AS(it[0], std::domain_error);
 | 
			
		||||
                    CHECK_THROWS_AS(it[1], std::domain_error);
 | 
			
		||||
                    CHECK_THROWS_WITH(it[0], "cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_WITH(it[1], "cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_AS(it[0], json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_AS(it[1], json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators");
 | 
			
		||||
                }
 | 
			
		||||
                {
 | 
			
		||||
                    auto it = j_object.cbegin();
 | 
			
		||||
                    CHECK_THROWS_AS(it[0], std::domain_error);
 | 
			
		||||
                    CHECK_THROWS_AS(it[1], std::domain_error);
 | 
			
		||||
                    CHECK_THROWS_WITH(it[0], "cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_WITH(it[1], "cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_AS(it[0], json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_AS(it[1], json::invalid_iterator);
 | 
			
		||||
                    CHECK_THROWS_WITH(it[0], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators");
 | 
			
		||||
                    CHECK_THROWS_WITH(it[1], "[json.exception.invalid_iterator.208] cannot use operator[] for object iterators");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue