Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
a4274d77
J
json
项目概览
畅游知识海洋
/
json
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
json
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
a4274d77
编写于
3月 03, 2017
作者:
N
Niels Lohmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔨
added user-defined exceptions 205-206
上级
875b2da9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
102 addition
and
98 deletion
+102
-98
src/json.hpp
src/json.hpp
+8
-7
src/json.hpp.re2c
src/json.hpp.re2c
+8
-7
test/src/unit-constructor1.cpp
test/src/unit-constructor1.cpp
+6
-4
test/src/unit-element_access1.cpp
test/src/unit-element_access1.cpp
+20
-20
test/src/unit-iterators1.cpp
test/src/unit-iterators1.cpp
+52
-52
test/src/unit-iterators2.cpp
test/src/unit-iterators2.cpp
+8
-8
未找到文件。
src/json.hpp
浏览文件 @
a4274d77
...
...
@@ -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"
));
}
/*!
...
...
src/json.hpp.re2c
浏览文件 @
a4274d77
...
...
@@ -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"));
}
/*!
...
...
test/src/unit-constructor1.cpp
浏览文件 @
a4274d77
...
...
@@ -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"
);
}
}
...
...
test/src/unit-element_access1.cpp
浏览文件 @
a4274d77
...
...
@@ -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"
);
}
}
}
...
...
test/src/unit-iterators1.cpp
浏览文件 @
a4274d77
...
...
@@ -229,22 +229,22 @@ TEST_CASE("iterators 1")
{
auto
it
=
j
.
begin
();
auto
cit
=
j_const
.
cbegin
();
CHECK_THROWS_AS
(
it
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
it
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_WITH
(
cit
.
key
(),
"cannot use key() for non-object iterators"
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
it
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
it
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
cit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
cit
.
key
(),
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
rit
.
key
(),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
rit
.
value
(),
std
::
out_of_range
);
CHECK_THROWS_AS
(
crit
.
key
(),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
crit
.
key
(),
json
::
invalid_iterat
or
);
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"
);
}
}
...
...
test/src/unit-iterators2.cpp
浏览文件 @
a4274d77
...
...
@@ -380,17 +380,17 @@ TEST_CASE("iterators 2")
{
{
auto
it
=
j_object
.
begin
();
CHECK_THROWS_AS
(
it
[
0
],
std
::
domain_err
or
);
CHECK_THROWS_AS
(
it
[
1
],
std
::
domain_err
or
);
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_iterat
or
);
CHECK_THROWS_AS
(
it
[
1
],
json
::
invalid_iterat
or
);
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_err
or
);
CHECK_THROWS_AS
(
it
[
1
],
std
::
domain_err
or
);
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_iterat
or
);
CHECK_THROWS_AS
(
it
[
1
],
json
::
invalid_iterat
or
);
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"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录