Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
9381f6c4
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,发现更多精彩内容 >>
未验证
提交
9381f6c4
编写于
3月 03, 2017
作者:
N
Niels Lohmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔨
added user-defined exceptions 201-202
Started implementing exceptions for invalid iterators.
上级
e291c6c3
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
81 addition
and
73 deletion
+81
-73
src/json.hpp
src/json.hpp
+20
-18
src/json.hpp.re2c
src/json.hpp.re2c
+20
-18
test/src/unit-constructor1.cpp
test/src/unit-constructor1.cpp
+16
-16
test/src/unit-element_access1.cpp
test/src/unit-element_access1.cpp
+6
-4
test/src/unit-element_access2.cpp
test/src/unit-element_access2.cpp
+6
-4
test/src/unit-modifiers.cpp
test/src/unit-modifiers.cpp
+13
-13
未找到文件。
src/json.hpp
浏览文件 @
9381f6c4
...
...
@@ -2415,8 +2415,9 @@ class basic_json
@pre Iterators @a first and @a last must be initialized. **This
precondition is enforced with an assertion.**
@throw std::domain_error if iterators are not compatible; that is, do not
belong to the same JSON value; example: `"iterators are not compatible"`
@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,
boolean, or string) where an out of range error can be detected easily;
example: `"iterators out of range"`
...
...
@@ -2442,7 +2443,7 @@ class basic_json
// make sure iterator fits the current value
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
...
...
@@ -4398,8 +4399,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 an iterator which does not belong to
the current JSON value; example: `"iterator does not fit current value"`
@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
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
out of range"`
...
...
@@ -4431,7 +4433,7 @@ class basic_json
// make sure iterator fits the current value
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
();
...
...
@@ -5655,8 +5657,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@complexity Constant plus linear in the distance between @a pos and end of
the container.
...
...
@@ -5673,7 +5675,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5708,8 +5710,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@complexity Linear in @a cnt plus linear in the distance between @a pos
and end of the container.
...
...
@@ -5726,7 +5728,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5750,8 +5752,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@throw std::domain_error if @a first and @a last do not belong to the same
JSON value; example: `"iterators do not fit"`
@throw std::domain_error if @a first or @a last are iterators into
...
...
@@ -5779,7 +5781,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5813,8 +5815,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@return iterator pointing to the first element inserted, or @a pos if
`ilist` is empty
...
...
@@ -5837,7 +5839,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
src/json.hpp.re2c
浏览文件 @
9381f6c4
...
...
@@ -2415,8 +2415,9 @@ class basic_json
@pre Iterators @a first and @a last must be initialized. **This
precondition is enforced with an assertion.**
@throw std::domain_error if iterators are not compatible; that is, do not
belong to the same JSON value; example: `"iterators are not compatible"`
@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,
boolean, or string) where an out of range error can be detected easily;
example: `"iterators out of range"`
...
...
@@ -2442,7 +2443,7 @@ class basic_json
// make sure iterator fits the current value
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
...
...
@@ -4398,8 +4399,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 an iterator which does not belong to
the current JSON value; example: `"iterator does not fit current value"`
@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
iterator (i.e., any iterator which is not `begin()`); example: `"iterator
out of range"`
...
...
@@ -4431,7 +4433,7 @@ class basic_json
// make sure iterator fits the current value
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();
...
...
@@ -5655,8 +5657,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@complexity Constant plus linear in the distance between @a pos and end of
the container.
...
...
@@ -5673,7 +5675,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5708,8 +5710,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@complexity Linear in @a cnt plus linear in the distance between @a pos
and end of the container.
...
...
@@ -5726,7 +5728,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5750,8 +5752,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@throw std::domain_error if @a first and @a last do not belong to the same
JSON value; example: `"iterators do not fit"`
@throw std::domain_error if @a first or @a last are iterators into
...
...
@@ -5779,7 +5781,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
@@ -5813,8 +5815,8 @@ class basic_json
@throw std::domain_error if called on JSON values other than arrays;
example: `"cannot use insert() with string"`
@throw
std::domain_error if @a pos is not an iterator of *this; example:
`"iterator does not fit current value"`
@throw
invalid_iterator.202 if @a pos is not an iterator of *this;
example:
`"iterator does not fit current value"`
@return iterator pointing to the first element inserted, or @a pos if
`ilist` is empty
...
...
@@ -5837,7 +5839,7 @@ class basic_json
// check if iterator pos fits to this JSON value
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
...
...
test/src/unit-constructor1.cpp
浏览文件 @
9381f6c4
...
...
@@ -1017,18 +1017,18 @@ TEST_CASE("constructors")
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_WITH
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_AS
(
json
(
jobject
.
begin
(),
jobject2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
begin
(),
jobject
.
end
()),
json
::
invalid_iterat
or
);
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
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
{
json
jobject
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
},
{
"d"
,
false
},
{
"e"
,
true
}};
json
jobject2
=
{{
"a"
,
"a"
},
{
"b"
,
1
},
{
"c"
,
17u
}};
CHECK_THROWS_AS
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_WITH
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_AS
(
json
(
jobject
.
cbegin
(),
jobject2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
json
::
invalid_iterat
or
);
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
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
}
...
...
@@ -1082,18 +1082,18 @@ TEST_CASE("constructors")
{
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
CHECK_THROWS_AS
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
std
::
domain_err
or
);
CHECK_THROWS_WITH
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
"iterators are not compatible"
);
CHECK_THROWS_AS
(
json
(
jarray
.
begin
(),
jarray2
.
end
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
begin
(),
jarray
.
end
()),
json
::
invalid_iterat
or
);
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
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
{
json
jarray
=
{
1
,
2
,
3
,
4
};
json
jarray2
=
{
2
,
3
,
4
,
5
};
CHECK_THROWS_AS
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
std
::
domain_err
or
);
CHECK_THROWS_WITH
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_WITH
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
"iterators are not compatible"
);
CHECK_THROWS_AS
(
json
(
jarray
.
cbegin
(),
jarray2
.
cend
()),
json
::
invalid_iterat
or
);
CHECK_THROWS_AS
(
json
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
json
::
invalid_iterat
or
);
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
()),
"
[json.exception.invalid_iterator.201]
iterators are not compatible"
);
}
}
}
...
...
test/src/unit-element_access1.cpp
浏览文件 @
9381f6c4
...
...
@@ -405,12 +405,13 @@ 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
()),
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
(
jarray2
.
begin
(),
jarray
.
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
()),
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
begin
(),
jarray
.
end
()),
...
...
@@ -421,12 +422,13 @@ 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
.
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
(
jarray2
.
cbegin
(),
jarray
.
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
()),
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jarray
.
erase
(
jarray2
.
cbegin
(),
jarray
.
cend
()),
...
...
test/src/unit-element_access2.cpp
浏览文件 @
9381f6c4
...
...
@@ -685,11 +685,12 @@ 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
()),
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
(
jobject2
.
begin
(),
jobject
.
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
()),
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
begin
(),
jobject
.
end
()),
...
...
@@ -700,11 +701,12 @@ 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
.
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
(
jobject2
.
cbegin
(),
jobject
.
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
()),
"iterators do not fit current value"
);
CHECK_THROWS_WITH
(
jobject
.
erase
(
jobject2
.
cbegin
(),
jobject
.
cend
()),
...
...
test/src/unit-modifiers.cpp
浏览文件 @
9381f6c4
...
...
@@ -662,22 +662,22 @@ TEST_CASE("modifiers")
// pass iterator to a different array
json
j_another_array
=
{
1
,
2
};
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
(),
j_value
),
std
::
domain_err
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
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
std
::
domain_err
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
),
"
iterator does not fit current value"
);
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
),
json
::
invalid_iterat
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
(),
j_yet_another_array
.
end
()),
json
::
invalid_iterator
);
CHECK_THROWS_AS
(
j_array
.
insert
(
j_another_array
.
end
(),
{
1
,
2
,
3
,
4
}),
json
::
invalid_iterat
or
);
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
10
),
"[json.exception.invalid_iterator.202]
iterator does not fit current 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
),
"iterator does not fit current value"
);
CHECK_THROWS_WITH
(
j_array
.
insert
(
j_another_array
.
end
(),
j_yet_another_array
.
begin
(),
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
(),
j_yet_another_array
.
begin
(),
j_yet_another_array
.
end
()),
"[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
}),
"iterator does not fit current value"
);
"
[json.exception.invalid_iterator.202]
iterator does not fit current value"
);
}
SECTION
(
"non-array type"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录