Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
9381f6c4
Unverified
Commit
9381f6c4
authored
Mar 03, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
added user-defined exceptions 201-202
Started implementing exceptions for invalid iterators.
parent
e291c6c3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
73 deletions
+81
-73
json.hpp
src/json.hpp
+20
-18
json.hpp.re2c
src/json.hpp.re2c
+20
-18
unit-constructor1.cpp
test/src/unit-constructor1.cpp
+16
-16
unit-element_access1.cpp
test/src/unit-element_access1.cpp
+6
-4
unit-element_access2.cpp
test/src/unit-element_access2.cpp
+6
-4
unit-modifiers.cpp
test/src/unit-modifiers.cpp
+13
-13
No files found.
src/json.hpp
View file @
9381f6c4
...
@@ -2415,8 +2415,9 @@ class basic_json
...
@@ -2415,8 +2415,9 @@ class basic_json
@pre Iterators @a first and @a last must be initialized. **This
@pre Iterators @a first and @a last must be initialized. **This
precondition is enforced with an assertion.**
precondition is enforced with an assertion.**
@throw std::domain_error if iterators are not compatible; that is, do not
@throw invalid_iterator.201 if iterators are not compatible; that is, do
belong to the same JSON value; example: `"iterators are not compatible"`
not belong to the same JSON value; example: `"iterators are not
compatible"`
@throw std::out_of_range if iterators are for a primitive type (number,
@throw std::out_of_range if iterators are for a primitive type (number,
boolean, or string) where an out of range error can be detected easily;
boolean, or string) where an out of range error can be detected easily;
example: `"iterators out of range"`
example: `"iterators out of range"`
...
@@ -2442,7 +2443,7 @@ class basic_json
...
@@ -2442,7 +2443,7 @@ class basic_json
// make sure iterator fits the current value
// make sure iterator fits the current value
if
(
first
.
m_object
!=
last
.
m_object
)
if
(
first
.
m_object
!=
last
.
m_object
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterators are not compatible"
));
JSON_THROW
(
invalid_iterator
(
201
,
"iterators are not compatible"
));
}
}
// copy type from first iterator
// copy type from first iterator
...
@@ -4398,8 +4399,9 @@ class basic_json
...
@@ -4398,8 +4399,9 @@ class basic_json
@throw std::domain_error if called on a `null` value; example: `"cannot
@throw std::domain_error if called on a `null` value; example: `"cannot
use erase() with null"`
use erase() with null"`
@throw std::domain_error if called on an iterator which does not belong to
@throw invalid_iterator.202 if called on an iterator which does not belong
the current JSON value; example: `"iterator does not fit current value"`
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 std::out_of_range if called on a primitive type with invalid
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
out of range"`
out of range"`
...
@@ -4431,7 +4433,7 @@ class basic_json
...
@@ -4431,7 +4433,7 @@ class basic_json
// make sure iterator fits the current value
// make sure iterator fits the current value
if
(
this
!=
pos
.
m_object
)
if
(
this
!=
pos
.
m_object
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterator does not fit current value"
));
JSON_THROW
(
invalid_iterator
(
202
,
"iterator does not fit current value"
));
}
}
IteratorType
result
=
end
();
IteratorType
result
=
end
();
...
@@ -5655,8 +5657,8 @@ class basic_json
...
@@ -5655,8 +5657,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@complexity Constant plus linear in the distance between @a pos and end of
@complexity Constant plus linear in the distance between @a pos and end of
the container.
the container.
...
@@ -5673,7 +5675,7 @@ class basic_json
...
@@ -5673,7 +5675,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if
(
pos
.
m_object
!=
this
)
if
(
pos
.
m_object
!=
this
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterator does not fit current value"
));
JSON_THROW
(
invalid_iterator
(
202
,
"iterator does not fit current value"
));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -5708,8 +5710,8 @@ class basic_json
...
@@ -5708,8 +5710,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@complexity Linear in @a cnt plus linear in the distance between @a pos
@complexity Linear in @a cnt plus linear in the distance between @a pos
and end of the container.
and end of the container.
...
@@ -5726,7 +5728,7 @@ class basic_json
...
@@ -5726,7 +5728,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if
(
pos
.
m_object
!=
this
)
if
(
pos
.
m_object
!=
this
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterator does not fit current value"
));
JSON_THROW
(
invalid_iterator
(
202
,
"iterator does not fit current value"
));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -5750,8 +5752,8 @@ class basic_json
...
@@ -5750,8 +5752,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@throw std::domain_error if @a first and @a last do not belong to the same
@throw std::domain_error if @a first and @a last do not belong to the same
JSON value; example: `"iterators do not fit"`
JSON value; example: `"iterators do not fit"`
@throw std::domain_error if @a first or @a last are iterators into
@throw std::domain_error if @a first or @a last are iterators into
...
@@ -5779,7 +5781,7 @@ class basic_json
...
@@ -5779,7 +5781,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if
(
pos
.
m_object
!=
this
)
if
(
pos
.
m_object
!=
this
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterator does not fit current value"
));
JSON_THROW
(
invalid_iterator
(
202
,
"iterator does not fit current value"
));
}
}
// check if range iterators belong to the same JSON object
// check if range iterators belong to the same JSON object
...
@@ -5813,8 +5815,8 @@ class basic_json
...
@@ -5813,8 +5815,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@return iterator pointing to the first element inserted, or @a pos if
@return iterator pointing to the first element inserted, or @a pos if
`ilist` is empty
`ilist` is empty
...
@@ -5837,7 +5839,7 @@ class basic_json
...
@@ -5837,7 +5839,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if
(
pos
.
m_object
!=
this
)
if
(
pos
.
m_object
!=
this
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterator does not fit current value"
));
JSON_THROW
(
invalid_iterator
(
202
,
"iterator does not fit current value"
));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
...
src/json.hpp.re2c
View file @
9381f6c4
...
@@ -2415,8 +2415,9 @@ class basic_json
...
@@ -2415,8 +2415,9 @@ class basic_json
@pre Iterators @a first and @a last must be initialized. **This
@pre Iterators @a first and @a last must be initialized. **This
precondition is enforced with an assertion.**
precondition is enforced with an assertion.**
@throw std::domain_error if iterators are not compatible; that is, do not
@throw invalid_iterator.201 if iterators are not compatible; that is, do
belong to the same JSON value; example: `"iterators are not compatible"`
not belong to the same JSON value; example: `"iterators are not
compatible"`
@throw std::out_of_range if iterators are for a primitive type (number,
@throw std::out_of_range if iterators are for a primitive type (number,
boolean, or string) where an out of range error can be detected easily;
boolean, or string) where an out of range error can be detected easily;
example: `"iterators out of range"`
example: `"iterators out of range"`
...
@@ -2442,7 +2443,7 @@ class basic_json
...
@@ -2442,7 +2443,7 @@ class basic_json
// make sure iterator fits the current value
// make sure iterator fits the current value
if (first.m_object != last.m_object)
if (first.m_object != last.m_object)
{
{
JSON_THROW(
std::domain_error(
"iterators are not compatible"));
JSON_THROW(
invalid_iterator(201,
"iterators are not compatible"));
}
}
// copy type from first iterator
// copy type from first iterator
...
@@ -4398,8 +4399,9 @@ class basic_json
...
@@ -4398,8 +4399,9 @@ class basic_json
@throw std::domain_error if called on a `null` value; example: `"cannot
@throw std::domain_error if called on a `null` value; example: `"cannot
use erase() with null"`
use erase() with null"`
@throw std::domain_error if called on an iterator which does not belong to
@throw invalid_iterator.202 if called on an iterator which does not belong
the current JSON value; example: `"iterator does not fit current value"`
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 std::out_of_range if called on a primitive type with invalid
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
out of range"`
out of range"`
...
@@ -4431,7 +4433,7 @@ class basic_json
...
@@ -4431,7 +4433,7 @@ class basic_json
// make sure iterator fits the current value
// make sure iterator fits the current value
if (this != pos.m_object)
if (this != pos.m_object)
{
{
JSON_THROW(
std::domain_error(
"iterator does not fit current value"));
JSON_THROW(
invalid_iterator(202,
"iterator does not fit current value"));
}
}
IteratorType result = end();
IteratorType result = end();
...
@@ -5655,8 +5657,8 @@ class basic_json
...
@@ -5655,8 +5657,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@complexity Constant plus linear in the distance between @a pos and end of
@complexity Constant plus linear in the distance between @a pos and end of
the container.
the container.
...
@@ -5673,7 +5675,7 @@ class basic_json
...
@@ -5673,7 +5675,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if (pos.m_object != this)
if (pos.m_object != this)
{
{
JSON_THROW(
std::domain_error(
"iterator does not fit current value"));
JSON_THROW(
invalid_iterator(202,
"iterator does not fit current value"));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -5708,8 +5710,8 @@ class basic_json
...
@@ -5708,8 +5710,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@complexity Linear in @a cnt plus linear in the distance between @a pos
@complexity Linear in @a cnt plus linear in the distance between @a pos
and end of the container.
and end of the container.
...
@@ -5726,7 +5728,7 @@ class basic_json
...
@@ -5726,7 +5728,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if (pos.m_object != this)
if (pos.m_object != this)
{
{
JSON_THROW(
std::domain_error(
"iterator does not fit current value"));
JSON_THROW(
invalid_iterator(202,
"iterator does not fit current value"));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -5750,8 +5752,8 @@ class basic_json
...
@@ -5750,8 +5752,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@throw std::domain_error if @a first and @a last do not belong to the same
@throw std::domain_error if @a first and @a last do not belong to the same
JSON value; example: `"iterators do not fit"`
JSON value; example: `"iterators do not fit"`
@throw std::domain_error if @a first or @a last are iterators into
@throw std::domain_error if @a first or @a last are iterators into
...
@@ -5779,7 +5781,7 @@ class basic_json
...
@@ -5779,7 +5781,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if (pos.m_object != this)
if (pos.m_object != this)
{
{
JSON_THROW(
std::domain_error(
"iterator does not fit current value"));
JSON_THROW(
invalid_iterator(202,
"iterator does not fit current value"));
}
}
// check if range iterators belong to the same JSON object
// check if range iterators belong to the same JSON object
...
@@ -5813,8 +5815,8 @@ class basic_json
...
@@ -5813,8 +5815,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
`"iterator does not fit current value"`
example:
`"iterator does not fit current value"`
@return iterator pointing to the first element inserted, or @a pos if
@return iterator pointing to the first element inserted, or @a pos if
`ilist` is empty
`ilist` is empty
...
@@ -5837,7 +5839,7 @@ class basic_json
...
@@ -5837,7 +5839,7 @@ class basic_json
// check if iterator pos fits to this JSON value
// check if iterator pos fits to this JSON value
if (pos.m_object != this)
if (pos.m_object != this)
{
{
JSON_THROW(
std::domain_error(
"iterator does not fit current value"));
JSON_THROW(
invalid_iterator(202,
"iterator does not fit current value"));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
...
test/src/unit-constructor1.cpp
View file @
9381f6c4
...
@@ -1017,18 +1017,18 @@ TEST_CASE("constructors")
...
@@ -1017,18 +1017,18 @@ TEST_CASE("constructors")
{
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
{
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
}
}
}
}
...
@@ -1082,18 +1082,18 @@ TEST_CASE("constructors")
...
@@ -1082,18 +1082,18 @@ TEST_CASE("constructors")
{
{
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
CHECK_THROWS_AS
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
{
{
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
CHECK_THROWS_AS
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
}
}
}
}
...
...
test/src/unit-element_access1.cpp
View file @
9381f6c4
...
@@ -405,12 +405,13 @@ TEST_CASE("element access 1")
...
@@ -405,12 +405,13 @@ TEST_CASE("element access 1")
{
{
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray2
=
{
"foo"
,
"bar"
};
json
jarray2
=
{
"foo"
,
"bar"
};
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
()),
"iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
()),
"[json.exception.invalid_iterator.202] iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
"iterators do not fit current value"
);
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
...
@@ -421,12 +422,13 @@ TEST_CASE("element access 1")
...
@@ -421,12 +422,13 @@ TEST_CASE("element access 1")
{
{
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray2
=
{
"foo"
,
"bar"
};
json
jarray2
=
{
"foo"
,
"bar"
};
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
()),
"iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
()),
"[json.exception.invalid_iterator.202] iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
"iterators do not fit current value"
);
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
...
...
test/src/unit-element_access2.cpp
View file @
9381f6c4
...
@@ -685,11 +685,12 @@ TEST_CASE("element access 2")
...
@@ -685,11 +685,12 @@ TEST_CASE("element access 2")
{
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject2
.
end
()),
std
::
domain_error
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
()),
"iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
()),
"[json.exception.invalid_iterator.202] iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
"iterators do not fit current value"
);
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
...
@@ -700,11 +701,12 @@ TEST_CASE("element access 2")
...
@@ -700,11 +701,12 @@ TEST_CASE("element access 2")
{
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_error
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
()),
"iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
()),
"[json.exception.invalid_iterator.202] iterator does not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
"iterators do not fit current value"
);
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
...
...
test/src/unit-modifiers.cpp
View file @
9381f6c4
...
@@ -662,22 +662,22 @@ TEST_CASE("modifiers")
...
@@ -662,22 +662,22 @@ TEST_CASE("modifiers")
// pass iterator to a different array
// pass iterator to a different array
json
j_another_array
=
{
1
,
2
};
json
j_another_array
=
{
1
,
2
};
json
j_yet_another_array
=
{
"first"
,
"second"
};
json
j_yet_another_array
=
{
"first"
,
"second"
};
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
10
),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
10
),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
j_value
),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
j_value
),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
10
,
11
),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
10
,
11
),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
j_yet_another_array
.
begin
(),
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
json
::
invalid_iterator
);
j_yet_another_array
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
{
1
,
2
,
3
,
4
}),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
{
1
,
2
,
3
,
4
}),
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
10
),
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
10
),
"
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_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
),
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
10
,
11
),
"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
(),
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
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
(),
{
1
,
2
,
3
,
4
}),
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"
)
SECTION
(
"non-array type"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment