Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
875b2da9
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,发现更多精彩内容 >>
未验证
提交
875b2da9
编写于
3月 03, 2017
作者:
N
Niels Lohmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔨
added user-defined exceptions 203-204
上级
9381f6c4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
118 addition
and
118 deletion
+118
-118
src/json.hpp
src/json.hpp
+7
-7
src/json.hpp.re2c
src/json.hpp.re2c
+7
-7
test/src/unit-constructor1.cpp
test/src/unit-constructor1.cpp
+40
-40
test/src/unit-element_access1.cpp
test/src/unit-element_access1.cpp
+52
-52
test/src/unit-element_access2.cpp
test/src/unit-element_access2.cpp
+12
-12
未找到文件。
src/json.hpp
浏览文件 @
875b2da9
...
...
@@ -2418,7 +2418,7 @@ class basic_json
@throw invalid_iterator.201 if iterators are not compatible; that is, do
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
invalid_iterator.204
if iterators are for a primitive type (number,
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
...
...
@@ -2460,7 +2460,7 @@ class basic_json
{
if
(
not
first
.
m_it
.
primitive_iterator
.
is_begin
()
or
not
last
.
m_it
.
primitive_iterator
.
is_end
())
{
JSON_THROW
(
std
::
out_of_range
(
"iterators out of range"
));
JSON_THROW
(
invalid_iterator
(
204
,
"iterators out of range"
));
}
break
;
}
...
...
@@ -4507,9 +4507,9 @@ class basic_json
@throw std::domain_error if called on a `null` value; example: `"cannot
use erase() with null"`
@throw
std::domain_error if called on iterators which does not belong to
the current JSON value; example: `"iterators do not fit current value"`
@throw
std::out_of_range
if called on a primitive type with invalid
@throw
invalid_iterator.203 if called on iterators which does not belong
t
o t
he current JSON value; example: `"iterators do not fit current value"`
@throw
invalid_iterator.204
if called on a primitive type with invalid
iterators (i.e., if `first != begin()` and `last != end()`); example:
`"iterators out of range"`
...
...
@@ -4540,7 +4540,7 @@ class basic_json
// make sure iterator fits the current value
if
(
this
!=
first
.
m_object
or
this
!=
last
.
m_object
)
{
JSON_THROW
(
std
::
domain_error
(
"iterators do not fit current value"
));
JSON_THROW
(
invalid_iterator
(
203
,
"iterators do not fit current value"
));
}
IteratorType
result
=
end
();
...
...
@@ -4555,7 +4555,7 @@ class basic_json
{
if
(
not
first
.
m_it
.
primitive_iterator
.
is_begin
()
or
not
last
.
m_it
.
primitive_iterator
.
is_end
())
{
JSON_THROW
(
std
::
out_of_range
(
"iterators out of range"
));
JSON_THROW
(
invalid_iterator
(
204
,
"iterators out of range"
));
}
if
(
is_string
())
...
...
src/json.hpp.re2c
浏览文件 @
875b2da9
...
...
@@ -2418,7 +2418,7 @@ class basic_json
@throw invalid_iterator.201 if iterators are not compatible; that is, do
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
invalid_iterator.204
if iterators are for a primitive type (number,
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
...
...
@@ -2460,7 +2460,7 @@ class basic_json
{
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
{
JSON_THROW(
std::out_of_range(
"iterators out of range"));
JSON_THROW(
invalid_iterator(204,
"iterators out of range"));
}
break;
}
...
...
@@ -4507,9 +4507,9 @@ class basic_json
@throw std::domain_error if called on a `null` value; example: `"cannot
use erase() with null"`
@throw
std::domain_error if called on iterators which does not belong to
the current JSON value; example: `"iterators do not fit current value"`
@throw
std::out_of_range
if called on a primitive type with invalid
@throw
invalid_iterator.203 if called on iterators which does not belong
t
o t
he current JSON value; example: `"iterators do not fit current value"`
@throw
invalid_iterator.204
if called on a primitive type with invalid
iterators (i.e., if `first != begin()` and `last != end()`); example:
`"iterators out of range"`
...
...
@@ -4540,7 +4540,7 @@ class basic_json
// make sure iterator fits the current value
if (this != first.m_object or this != last.m_object)
{
JSON_THROW(
std::domain_error(
"iterators do not fit current value"));
JSON_THROW(
invalid_iterator(203,
"iterators do not fit current value"));
}
IteratorType result = end();
...
...
@@ -4555,7 +4555,7 @@ class basic_json
{
if (not first.m_it.primitive_iterator.is_begin() or not last.m_it.primitive_iterator.is_end())
{
JSON_THROW(
std::out_of_range(
"iterators out of range"));
JSON_THROW(
invalid_iterator(204,
"iterators out of range"));
}
if (is_string())
...
...
test/src/unit-constructor1.cpp
浏览文件 @
875b2da9
...
...
@@ -1193,17 +1193,17 @@ TEST_CASE("constructors")
{
{
json
j
=
"foo"
;
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
"bar"
;
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -1211,17 +1211,17 @@ TEST_CASE("constructors")
{
{
json
j
=
false
;
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
true
;
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -1229,17 +1229,17 @@ TEST_CASE("constructors")
{
{
json
j
=
17
;
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
17
;
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -1247,17 +1247,17 @@ TEST_CASE("constructors")
{
{
json
j
=
17u
;
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
17u
;
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -1265,17 +1265,17 @@ TEST_CASE("constructors")
{
{
json
j
=
23.42
;
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
23.42
;
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
json
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
json
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
json
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
}
...
...
test/src/unit-element_access1.cpp
浏览文件 @
875b2da9
...
...
@@ -406,35 +406,35 @@ TEST_CASE("element access 1")
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray2
=
{
"foo"
,
"bar"
};
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
begin
(),
jarray2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray2
.
end
()),
json
::
invalid_iterat
or
);
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
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray2
.
end
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
}
{
json
jarray
=
{
1
,
1u
,
true
,
nullptr
,
"string"
,
42.23
,
json
::
object
(),
{
1
,
2
,
3
}};
json
jarray2
=
{
"foo"
,
"bar"
};
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray2
.
cend
()),
json
::
invalid_iterat
or
);
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
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray2
.
cend
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
}
}
}
...
...
@@ -859,17 +859,17 @@ TEST_CASE("element access 1")
{
{
json
j
=
"foo"
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
"bar"
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -877,17 +877,17 @@ TEST_CASE("element access 1")
{
{
json
j
=
false
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
true
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -895,17 +895,17 @@ TEST_CASE("element access 1")
{
{
json
j
=
17
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
17
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -913,17 +913,17 @@ TEST_CASE("element access 1")
{
{
json
j
=
17u
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
17u
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
...
...
@@ -931,17 +931,17 @@ TEST_CASE("element access 1")
{
{
json
j
=
23.42
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
end
(),
j
.
end
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
begin
(),
j
.
begin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
{
json
j
=
23.42
;
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
std
::
out_of_range
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
std
::
out_of_range
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"iterators out of range"
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cend
(),
j
.
cend
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
CHECK_THROWS_WITH
(
j
.
erase
(
j
.
cbegin
(),
j
.
cbegin
()),
"
[json.exception.invalid_iterator.204]
iterators out of range"
);
}
}
}
...
...
test/src/unit-element_access2.cpp
浏览文件 @
875b2da9
...
...
@@ -686,33 +686,33 @@ TEST_CASE("element access 2")
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
begin
(),
jobject2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject2
.
end
()),
json
::
invalid_iterat
or
);
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
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject2
.
end
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
}
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject2
.
cend
()),
json
::
invalid_iterat
or
);
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
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject2
.
cend
()),
"iterators do not fit current value"
);
"
[json.exception.invalid_iterator.203]
iterators do not fit current value"
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录