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
0c40c8e3
Unverified
Commit
0c40c8e3
authored
Mar 03, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
added user-defined exceptions 2xx
parent
a4274d77
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
90 additions
and
88 deletions
+90
-88
json.hpp
src/json.hpp
+15
-15
json.hpp.re2c
src/json.hpp.re2c
+15
-15
unit-algorithms.cpp
test/src/unit-algorithms.cpp
+3
-2
unit-class_const_iterator.cpp
test/src/unit-class_const_iterator.cpp
+8
-8
unit-class_iterator.cpp
test/src/unit-class_iterator.cpp
+8
-8
unit-element_access1.cpp
test/src/unit-element_access1.cpp
+8
-8
unit-iterators1.cpp
test/src/unit-iterators1.cpp
+28
-28
unit-iterators2.cpp
test/src/unit-iterators2.cpp
+0
-0
unit-modifiers.cpp
test/src/unit-modifiers.cpp
+5
-4
No files found.
src/json.hpp
View file @
0c40c8e3
...
@@ -5755,9 +5755,9 @@ class basic_json
...
@@ -5755,9 +5755,9 @@ class basic_json
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"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 sam
e
@throw
invalid_iterator.210 if @a first and @a last do not belong to th
e
JSON value; example: `"iterators do not fit"`
same
JSON value; example: `"iterators do not fit"`
@throw
std::domain_error
if @a first or @a last are iterators into
@throw
invalid_iterator.211
if @a first or @a last are iterators into
container for which insert is called; example: `"passed iterators may not
container for which insert is called; example: `"passed iterators may not
belong to container"`
belong to container"`
...
@@ -5788,12 +5788,12 @@ class basic_json
...
@@ -5788,12 +5788,12 @@ class basic_json
// check if range iterators belong to the same JSON object
// check if range iterators belong to the same JSON object
if
(
first
.
m_object
!=
last
.
m_object
)
if
(
first
.
m_object
!=
last
.
m_object
)
{
{
JSON_THROW
(
std
::
domain_error
(
"iterators do not fit"
));
JSON_THROW
(
invalid_iterator
(
210
,
"iterators do not fit"
));
}
}
if
(
first
.
m_object
==
this
or
last
.
m_object
==
this
)
if
(
first
.
m_object
==
this
or
last
.
m_object
==
this
)
{
{
JSON_THROW
(
std
::
domain_error
(
"passed iterators may not belong to container"
));
JSON_THROW
(
invalid_iterator
(
211
,
"passed iterators may not belong to container"
));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -9288,7 +9288,7 @@ class basic_json
...
@@ -9288,7 +9288,7 @@ class basic_json
case
basic_json
:
:
value_t
::
null
:
case
basic_json
:
:
value_t
::
null
:
{
{
JSON_THROW
(
std
::
out_of_range
(
"cannot get value"
));
JSON_THROW
(
invalid_iterator
(
214
,
"cannot get value"
));
}
}
default
:
default
:
...
@@ -9298,7 +9298,7 @@ class basic_json
...
@@ -9298,7 +9298,7 @@ class basic_json
return
*
m_object
;
return
*
m_object
;
}
}
JSON_THROW
(
std
::
out_of_range
(
"cannot get value"
));
JSON_THROW
(
invalid_iterator
(
214
,
"cannot get value"
));
}
}
}
}
}
}
...
@@ -9332,7 +9332,7 @@ class basic_json
...
@@ -9332,7 +9332,7 @@ class basic_json
return
m_object
;
return
m_object
;
}
}
JSON_THROW
(
std
::
out_of_range
(
"cannot get value"
));
JSON_THROW
(
invalid_iterator
(
214
,
"cannot get value"
));
}
}
}
}
}
}
...
@@ -9432,7 +9432,7 @@ class basic_json
...
@@ -9432,7 +9432,7 @@ class basic_json
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
m_object
!=
other
.
m_object
)
if
(
m_object
!=
other
.
m_object
)
{
{
JSON_THROW
(
std
::
domain_error
(
"cannot compare iterators of different containers"
));
JSON_THROW
(
invalid_iterator
(
212
,
"cannot compare iterators of different containers"
));
}
}
assert
(
m_object
!=
nullptr
);
assert
(
m_object
!=
nullptr
);
...
@@ -9474,7 +9474,7 @@ class basic_json
...
@@ -9474,7 +9474,7 @@ class basic_json
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if
(
m_object
!=
other
.
m_object
)
if
(
m_object
!=
other
.
m_object
)
{
{
JSON_THROW
(
std
::
domain_error
(
"cannot compare iterators of different containers"
));
JSON_THROW
(
invalid_iterator
(
212
,
"cannot compare iterators of different containers"
));
}
}
assert
(
m_object
!=
nullptr
);
assert
(
m_object
!=
nullptr
);
...
@@ -9483,7 +9483,7 @@ class basic_json
...
@@ -9483,7 +9483,7 @@ class basic_json
{
{
case
basic_json
:
:
value_t
::
object
:
case
basic_json
:
:
value_t
::
object
:
{
{
JSON_THROW
(
std
::
domain_error
(
"cannot compare order of object iterators"
));
JSON_THROW
(
invalid_iterator
(
213
,
"cannot compare order of object iterators"
));
}
}
case
basic_json
:
:
value_t
::
array
:
case
basic_json
:
:
value_t
::
array
:
...
@@ -9537,7 +9537,7 @@ class basic_json
...
@@ -9537,7 +9537,7 @@ class basic_json
{
{
case
basic_json
:
:
value_t
::
object
:
case
basic_json
:
:
value_t
::
object
:
{
{
JSON_THROW
(
std
::
domain_error
(
"cannot use offsets with object iterators"
));
JSON_THROW
(
invalid_iterator
(
209
,
"cannot use offsets with object iterators"
));
}
}
case
basic_json
:
:
value_t
::
array
:
case
basic_json
:
:
value_t
::
array
:
...
@@ -9599,7 +9599,7 @@ class basic_json
...
@@ -9599,7 +9599,7 @@ class basic_json
{
{
case
basic_json
:
:
value_t
::
object
:
case
basic_json
:
:
value_t
::
object
:
{
{
JSON_THROW
(
std
::
domain_error
(
"cannot use offsets with object iterators"
));
JSON_THROW
(
invalid_iterator
(
209
,
"cannot use offsets with object iterators"
));
}
}
case
basic_json
:
:
value_t
::
array
:
case
basic_json
:
:
value_t
::
array
:
...
@@ -9636,7 +9636,7 @@ class basic_json
...
@@ -9636,7 +9636,7 @@ class basic_json
case
basic_json
:
:
value_t
::
null
:
case
basic_json
:
:
value_t
::
null
:
{
{
JSON_THROW
(
std
::
out_of_range
(
"cannot get value"
));
JSON_THROW
(
invalid_iterator
(
214
,
"cannot get value"
));
}
}
default
:
default
:
...
@@ -9646,7 +9646,7 @@ class basic_json
...
@@ -9646,7 +9646,7 @@ class basic_json
return
*
m_object
;
return
*
m_object
;
}
}
JSON_THROW
(
std
::
out_of_range
(
"cannot get value"
));
JSON_THROW
(
invalid_iterator
(
214
,
"cannot get value"
));
}
}
}
}
}
}
...
...
src/json.hpp.re2c
View file @
0c40c8e3
...
@@ -5755,9 +5755,9 @@ class basic_json
...
@@ -5755,9 +5755,9 @@ class basic_json
example: `"cannot use insert() with string"`
example: `"cannot use insert() with string"`
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
@throw invalid_iterator.202 if @a pos is not an iterator of *this;
example: `"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 sam
e
@throw
invalid_iterator.210 if @a first and @a last do not belong to th
e
JSON value; example: `"iterators do not fit"`
same
JSON value; example: `"iterators do not fit"`
@throw
std::domain_error
if @a first or @a last are iterators into
@throw
invalid_iterator.211
if @a first or @a last are iterators into
container for which insert is called; example: `"passed iterators may not
container for which insert is called; example: `"passed iterators may not
belong to container"`
belong to container"`
...
@@ -5788,12 +5788,12 @@ class basic_json
...
@@ -5788,12 +5788,12 @@ class basic_json
// check if range iterators belong to the same JSON object
// check if range iterators belong to the same JSON object
if (first.m_object != last.m_object)
if (first.m_object != last.m_object)
{
{
JSON_THROW(
std::domain_error(
"iterators do not fit"));
JSON_THROW(
invalid_iterator(210,
"iterators do not fit"));
}
}
if (first.m_object == this or last.m_object == this)
if (first.m_object == this or last.m_object == this)
{
{
JSON_THROW(
std::domain_error(
"passed iterators may not belong to container"));
JSON_THROW(
invalid_iterator(211,
"passed iterators may not belong to container"));
}
}
// insert to array and return iterator
// insert to array and return iterator
...
@@ -9288,7 +9288,7 @@ class basic_json
...
@@ -9288,7 +9288,7 @@ class basic_json
case basic_json::value_t::null:
case basic_json::value_t::null:
{
{
JSON_THROW(
std::out_of_range(
"cannot get value"));
JSON_THROW(
invalid_iterator(214,
"cannot get value"));
}
}
default:
default:
...
@@ -9298,7 +9298,7 @@ class basic_json
...
@@ -9298,7 +9298,7 @@ class basic_json
return *m_object;
return *m_object;
}
}
JSON_THROW(
std::out_of_range(
"cannot get value"));
JSON_THROW(
invalid_iterator(214,
"cannot get value"));
}
}
}
}
}
}
...
@@ -9332,7 +9332,7 @@ class basic_json
...
@@ -9332,7 +9332,7 @@ class basic_json
return m_object;
return m_object;
}
}
JSON_THROW(
std::out_of_range(
"cannot get value"));
JSON_THROW(
invalid_iterator(214,
"cannot get value"));
}
}
}
}
}
}
...
@@ -9432,7 +9432,7 @@ class basic_json
...
@@ -9432,7 +9432,7 @@ class basic_json
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if (m_object != other.m_object)
if (m_object != other.m_object)
{
{
JSON_THROW(
std::domain_error(
"cannot compare iterators of different containers"));
JSON_THROW(
invalid_iterator(212,
"cannot compare iterators of different containers"));
}
}
assert(m_object != nullptr);
assert(m_object != nullptr);
...
@@ -9474,7 +9474,7 @@ class basic_json
...
@@ -9474,7 +9474,7 @@ class basic_json
// if objects are not the same, the comparison is undefined
// if objects are not the same, the comparison is undefined
if (m_object != other.m_object)
if (m_object != other.m_object)
{
{
JSON_THROW(
std::domain_error(
"cannot compare iterators of different containers"));
JSON_THROW(
invalid_iterator(212,
"cannot compare iterators of different containers"));
}
}
assert(m_object != nullptr);
assert(m_object != nullptr);
...
@@ -9483,7 +9483,7 @@ class basic_json
...
@@ -9483,7 +9483,7 @@ class basic_json
{
{
case basic_json::value_t::object:
case basic_json::value_t::object:
{
{
JSON_THROW(
std::domain_error(
"cannot compare order of object iterators"));
JSON_THROW(
invalid_iterator(213,
"cannot compare order of object iterators"));
}
}
case basic_json::value_t::array:
case basic_json::value_t::array:
...
@@ -9537,7 +9537,7 @@ class basic_json
...
@@ -9537,7 +9537,7 @@ class basic_json
{
{
case basic_json::value_t::object:
case basic_json::value_t::object:
{
{
JSON_THROW(
std::domain_error(
"cannot use offsets with object iterators"));
JSON_THROW(
invalid_iterator(209,
"cannot use offsets with object iterators"));
}
}
case basic_json::value_t::array:
case basic_json::value_t::array:
...
@@ -9599,7 +9599,7 @@ class basic_json
...
@@ -9599,7 +9599,7 @@ class basic_json
{
{
case basic_json::value_t::object:
case basic_json::value_t::object:
{
{
JSON_THROW(
std::domain_error(
"cannot use offsets with object iterators"));
JSON_THROW(
invalid_iterator(209,
"cannot use offsets with object iterators"));
}
}
case basic_json::value_t::array:
case basic_json::value_t::array:
...
@@ -9636,7 +9636,7 @@ class basic_json
...
@@ -9636,7 +9636,7 @@ class basic_json
case basic_json::value_t::null:
case basic_json::value_t::null:
{
{
JSON_THROW(
std::out_of_range(
"cannot get value"));
JSON_THROW(
invalid_iterator(214,
"cannot get value"));
}
}
default:
default:
...
@@ -9646,7 +9646,7 @@ class basic_json
...
@@ -9646,7 +9646,7 @@ class basic_json
return *m_object;
return *m_object;
}
}
JSON_THROW(
std::out_of_range(
"cannot get value"));
JSON_THROW(
invalid_iterator(214,
"cannot get value"));
}
}
}
}
}
}
...
...
test/src/unit-algorithms.cpp
View file @
0c40c8e3
...
@@ -240,8 +240,9 @@ TEST_CASE("algorithms")
...
@@ -240,8 +240,9 @@ TEST_CASE("algorithms")
SECTION
(
"sorting an object"
)
SECTION
(
"sorting an object"
)
{
{
json
j
({{
"one"
,
1
},
{
"two"
,
2
}});
json
j
({{
"one"
,
1
},
{
"two"
,
2
}});
CHECK_THROWS_AS
(
std
::
sort
(
j
.
begin
(),
j
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
std
::
sort
(
j
.
begin
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
std
::
sort
(
j
.
begin
(),
j
.
end
()),
"cannot use offsets with object iterators"
);
CHECK_THROWS_WITH
(
std
::
sort
(
j
.
begin
(),
j
.
end
()),
"[json.exception.invalid_iterator.209] cannot use offsets with object iterators"
);
}
}
}
}
...
...
test/src/unit-class_const_iterator.cpp
View file @
0c40c8e3
...
@@ -147,8 +147,8 @@ TEST_CASE("const_iterator class")
...
@@ -147,8 +147,8 @@ TEST_CASE("const_iterator class")
{
{
json
j
(
json
::
value_t
::
null
);
json
j
(
json
::
value_t
::
null
);
json
::
const_iterator
it
=
j
.
cbegin
();
json
::
const_iterator
it
=
j
.
cbegin
();
CHECK_THROWS_AS
(
*
it
,
std
::
out_of_range
);
CHECK_THROWS_AS
(
*
it
,
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
*
it
,
"cannot get value"
);
CHECK_THROWS_WITH
(
*
it
,
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"number"
)
SECTION
(
"number"
)
...
@@ -157,8 +157,8 @@ TEST_CASE("const_iterator class")
...
@@ -157,8 +157,8 @@ TEST_CASE("const_iterator class")
json
::
const_iterator
it
=
j
.
cbegin
();
json
::
const_iterator
it
=
j
.
cbegin
();
CHECK
(
*
it
==
json
(
17
));
CHECK
(
*
it
==
json
(
17
));
it
=
j
.
cend
();
it
=
j
.
cend
();
CHECK_THROWS_AS
(
*
it
,
std
::
out_of_range
);
CHECK_THROWS_AS
(
*
it
,
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
*
it
,
"cannot get value"
);
CHECK_THROWS_WITH
(
*
it
,
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"object"
)
SECTION
(
"object"
)
...
@@ -182,8 +182,8 @@ TEST_CASE("const_iterator class")
...
@@ -182,8 +182,8 @@ TEST_CASE("const_iterator class")
{
{
json
j
(
json
::
value_t
::
null
);
json
j
(
json
::
value_t
::
null
);
json
::
const_iterator
it
=
j
.
cbegin
();
json
::
const_iterator
it
=
j
.
cbegin
();
CHECK_THROWS_AS
(
it
->
type_name
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
it
->
type_name
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"number"
)
SECTION
(
"number"
)
...
@@ -192,8 +192,8 @@ TEST_CASE("const_iterator class")
...
@@ -192,8 +192,8 @@ TEST_CASE("const_iterator class")
json
::
const_iterator
it
=
j
.
cbegin
();
json
::
const_iterator
it
=
j
.
cbegin
();
CHECK
(
it
->
type_name
()
==
"number"
);
CHECK
(
it
->
type_name
()
==
"number"
);
it
=
j
.
cend
();
it
=
j
.
cend
();
CHECK_THROWS_AS
(
it
->
type_name
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
it
->
type_name
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"object"
)
SECTION
(
"object"
)
...
...
test/src/unit-class_iterator.cpp
View file @
0c40c8e3
...
@@ -131,8 +131,8 @@ TEST_CASE("iterator class")
...
@@ -131,8 +131,8 @@ TEST_CASE("iterator class")
{
{
json
j
(
json
::
value_t
::
null
);
json
j
(
json
::
value_t
::
null
);
json
::
iterator
it
=
j
.
begin
();
json
::
iterator
it
=
j
.
begin
();
CHECK_THROWS_AS
(
*
it
,
std
::
out_of_range
);
CHECK_THROWS_AS
(
*
it
,
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
*
it
,
"cannot get value"
);
CHECK_THROWS_WITH
(
*
it
,
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"number"
)
SECTION
(
"number"
)
...
@@ -141,8 +141,8 @@ TEST_CASE("iterator class")
...
@@ -141,8 +141,8 @@ TEST_CASE("iterator class")
json
::
iterator
it
=
j
.
begin
();
json
::
iterator
it
=
j
.
begin
();
CHECK
(
*
it
==
json
(
17
));
CHECK
(
*
it
==
json
(
17
));
it
=
j
.
end
();
it
=
j
.
end
();
CHECK_THROWS_AS
(
*
it
,
std
::
out_of_range
);
CHECK_THROWS_AS
(
*
it
,
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
*
it
,
"cannot get value"
);
CHECK_THROWS_WITH
(
*
it
,
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"object"
)
SECTION
(
"object"
)
...
@@ -166,8 +166,8 @@ TEST_CASE("iterator class")
...
@@ -166,8 +166,8 @@ TEST_CASE("iterator class")
{
{
json
j
(
json
::
value_t
::
null
);
json
j
(
json
::
value_t
::
null
);
json
::
iterator
it
=
j
.
begin
();
json
::
iterator
it
=
j
.
begin
();
CHECK_THROWS_AS
(
it
->
type_name
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
it
->
type_name
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"number"
)
SECTION
(
"number"
)
...
@@ -176,8 +176,8 @@ TEST_CASE("iterator class")
...
@@ -176,8 +176,8 @@ TEST_CASE("iterator class")
json
::
iterator
it
=
j
.
begin
();
json
::
iterator
it
=
j
.
begin
();
CHECK
(
it
->
type_name
()
==
"number"
);
CHECK
(
it
->
type_name
()
==
"number"
);
it
=
j
.
end
();
it
=
j
.
end
();
CHECK_THROWS_AS
(
it
->
type_name
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
it
->
type_name
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
it
->
type_name
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
SECTION
(
"object"
)
SECTION
(
"object"
)
...
...
test/src/unit-element_access1.cpp
View file @
0c40c8e3
...
@@ -501,17 +501,17 @@ TEST_CASE("element access 1")
...
@@ -501,17 +501,17 @@ TEST_CASE("element access 1")
{
{
{
{
json
j
;
json
j
;
CHECK_THROWS_AS
(
j
.
front
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
front
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
back
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
back
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
front
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
j
.
front
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
j
.
back
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
j
.
back
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
{
{
const
json
j
{};
const
json
j
{};
CHECK_THROWS_AS
(
j
.
front
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
front
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
back
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
back
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
front
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
j
.
front
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
j
.
back
(),
"cannot get value"
);
CHECK_THROWS_WITH
(
j
.
back
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
...
test/src/unit-iterators1.cpp
View file @
0c40c8e3
...
@@ -239,13 +239,13 @@ TEST_CASE("iterators 1")
...
@@ -239,13 +239,13 @@ TEST_CASE("iterators 1")
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
@@ -443,13 +443,13 @@ TEST_CASE("iterators 1")
...
@@ -443,13 +443,13 @@ TEST_CASE("iterators 1")
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
@@ -1017,13 +1017,13 @@ TEST_CASE("iterators 1")
...
@@ -1017,13 +1017,13 @@ TEST_CASE("iterators 1")
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
@@ -1221,13 +1221,13 @@ TEST_CASE("iterators 1")
...
@@ -1221,13 +1221,13 @@ TEST_CASE("iterators 1")
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
@@ -1425,13 +1425,13 @@ TEST_CASE("iterators 1")
...
@@ -1425,13 +1425,13 @@ TEST_CASE("iterators 1")
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
...
@@ -1490,24 +1490,24 @@ TEST_CASE("iterators 1")
...
@@ -1490,24 +1490,24 @@ TEST_CASE("iterators 1")
auto
it
=
j
.
begin
();
auto
it
=
j
.
begin
();
auto
cit
=
j_const
.
cbegin
();
auto
cit
=
j_const
.
cbegin
();
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
it
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
it
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
cit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
cit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
it
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
it
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
cit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
auto
rit
=
j
.
rend
();
auto
rit
=
j
.
rend
();
auto
crit
=
j
.
crend
();
auto
crit
=
j
.
crend
();
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
rit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
crit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
value
(),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
rit
.
key
(),
"[json.exception.invalid_iterator.207] 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
(
rit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
CHECK_THROWS_WITH
(
crit
.
key
(),
"[json.exception.invalid_iterator.207] 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"
);
CHECK_THROWS_WITH
(
crit
.
value
(),
"
[json.exception.invalid_iterator.214]
cannot get value"
);
}
}
}
}
}
}
...
...
test/src/unit-iterators2.cpp
View file @
0c40c8e3
This diff is collapsed.
Click to expand it.
test/src/unit-modifiers.cpp
View file @
0c40c8e3
...
@@ -616,14 +616,15 @@ TEST_CASE("modifiers")
...
@@ -616,14 +616,15 @@ TEST_CASE("modifiers")
{
{
json
j_other_array2
=
{
"first"
,
"second"
};
json
j_other_array2
=
{
"first"
,
"second"
};
CHECK_THROWS_AS
(
j_array
.
insert
(
j_array
.
end
(),
j_array
.
begin
(),
j_array
.
end
()),
std
::
domain_error
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_array
.
end
(),
j_array
.
begin
(),
j_array
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_array
.
end
(),
j_other_array
.
begin
(),
j_other_array2
.
end
()),
CHECK_THROWS_AS
(
j_array
.
insert
(
j_array
.
end
(),
j_other_array
.
begin
(),
j_other_array2
.
end
()),
std
::
domain_err
or
);
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_array
.
end
(),
j_array
.
begin
(),
j_array
.
end
()),
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_array
.
end
(),
j_array
.
begin
(),
j_array
.
end
()),
"passed iterators may not belong to container"
);
"
[json.exception.invalid_iterator.211]
passed iterators may not belong to container"
);
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_array
.
end
(),
j_other_array
.
begin
(),
j_other_array2
.
end
()),
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_array
.
end
(),
j_other_array
.
begin
(),
j_other_array2
.
end
()),
"iterators do not fit"
);
"
[json.exception.invalid_iterator.210]
iterators do not fit"
);
}
}
}
}
...
...
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