Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
aa842b4a
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,发现更多精彩内容 >>
未验证
提交
aa842b4a
编写于
3月 05, 2017
作者:
N
Niels Lohmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🔨
added user-defined exceptions 305
上级
f473f74f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
124 addition
and
112 deletion
+124
-112
src/json.hpp
src/json.hpp
+17
-17
src/json.hpp.re2c
src/json.hpp.re2c
+17
-17
test/src/unit-element_access1.cpp
test/src/unit-element_access1.cpp
+26
-26
test/src/unit-element_access2.cpp
test/src/unit-element_access2.cpp
+64
-52
未找到文件。
src/json.hpp
浏览文件 @
aa842b4a
...
...
@@ -3828,8 +3828,8 @@ class basic_json
@return reference to the element at index @a idx
@throw
std::domain_error if JSON is not an array or null; example:
`"cannot use operator[] with string"`
@throw
type_error.305 if JSON is not an array or null; example: `"cannot
use operator[] with string"
@complexity Constant if @a idx is in the range of the array. Otherwise
linear in `idx - size()`.
...
...
@@ -3864,7 +3864,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
@@ -3876,7 +3876,7 @@ class basic_json
@return const reference to the element at index @a idx
@throw
std::domain_error
if JSON is not an array; example: `"cannot use
@throw
type_error.305
if JSON is not an array; example: `"cannot use
operator[] with null"`
@complexity Constant.
...
...
@@ -3894,7 +3894,7 @@ class basic_json
return
m_value
.
array
->
operator
[](
idx
);
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
@@ -3910,8 +3910,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -3940,7 +3940,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
@@ -3959,7 +3959,7 @@ class basic_json
@pre The element with key @a key must exist. **This precondition is
enforced with an assertion.**
@throw
std::domain_error
if JSON is not an object; example: `"cannot use
@throw
type_error.305
if JSON is not an object; example: `"cannot use
operator[] with null"`
@complexity Logarithmic in the size of the container.
...
...
@@ -3982,7 +3982,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
@@ -3998,8 +3998,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4066,8 +4066,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4097,7 +4097,7 @@ class basic_json
return
m_value
.
object
->
operator
[](
key
);
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
@@ -4116,7 +4116,7 @@ class basic_json
@pre The element with key @a key must exist. **This precondition is
enforced with an assertion.**
@throw
std::domain_error
if JSON is not an object; example: `"cannot use
@throw
type_error.305
if JSON is not an object; example: `"cannot use
operator[] with null"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4140,7 +4140,7 @@ class basic_json
return
m_value
.
object
->
find
(
key
)
->
second
;
}
JSON_THROW
(
std
::
domain_error
(
"cannot use operator[] with "
+
type_name
()));
JSON_THROW
(
type_error
(
305
,
"cannot use operator[] with "
+
type_name
()));
}
/*!
...
...
src/json.hpp.re2c
浏览文件 @
aa842b4a
...
...
@@ -3828,8 +3828,8 @@ class basic_json
@return reference to the element at index @a idx
@throw
std::domain_error if JSON is not an array or null; example:
`"cannot use operator[] with string"`
@throw
type_error.305 if JSON is not an array or null; example: `"cannot
use operator[] with string"
@complexity Constant if @a idx is in the range of the array. Otherwise
linear in `idx - size()`.
...
...
@@ -3864,7 +3864,7 @@ class basic_json
return m_value.array->operator[](idx);
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
@@ -3876,7 +3876,7 @@ class basic_json
@return const reference to the element at index @a idx
@throw
std::domain_error
if JSON is not an array; example: `"cannot use
@throw
type_error.305
if JSON is not an array; example: `"cannot use
operator[] with null"`
@complexity Constant.
...
...
@@ -3894,7 +3894,7 @@ class basic_json
return m_value.array->operator[](idx);
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
@@ -3910,8 +3910,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -3940,7 +3940,7 @@ class basic_json
return m_value.object->operator[](key);
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
@@ -3959,7 +3959,7 @@ class basic_json
@pre The element with key @a key must exist. **This precondition is
enforced with an assertion.**
@throw
std::domain_error
if JSON is not an object; example: `"cannot use
@throw
type_error.305
if JSON is not an object; example: `"cannot use
operator[] with null"`
@complexity Logarithmic in the size of the container.
...
...
@@ -3982,7 +3982,7 @@ class basic_json
return m_value.object->find(key)->second;
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
@@ -3998,8 +3998,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4066,8 +4066,8 @@ class basic_json
@return reference to the element at key @a key
@throw
std::domain_error if JSON is not an object or null; example:
`"cannot
use operator[] with string"`
@throw
type_error.305 if JSON is not an object or null; example: `"cannot
use operator[] with string"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4097,7 +4097,7 @@ class basic_json
return m_value.object->operator[](key);
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
@@ -4116,7 +4116,7 @@ class basic_json
@pre The element with key @a key must exist. **This precondition is
enforced with an assertion.**
@throw
std::domain_error
if JSON is not an object; example: `"cannot use
@throw
type_error.305
if JSON is not an object; example: `"cannot use
operator[] with null"`
@complexity Logarithmic in the size of the container.
...
...
@@ -4140,7 +4140,7 @@ class basic_json
return m_value.object->find(key)->second;
}
JSON_THROW(
std::domain_error(
"cannot use operator[] with " + type_name()));
JSON_THROW(
type_error(305,
"cannot use operator[] with " + type_name()));
}
/*!
...
...
test/src/unit-element_access1.cpp
浏览文件 @
aa842b4a
...
...
@@ -191,8 +191,8 @@ TEST_CASE("element access 1")
json
j_nonarray
(
json
::
value_t
::
null
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_NOTHROW
(
j_nonarray
[
0
]);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with null"
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with null"
);
}
SECTION
(
"implicit transformation to properly filled array"
)
...
...
@@ -207,60 +207,60 @@ TEST_CASE("element access 1")
{
json
j_nonarray
(
json
::
value_t
::
boolean
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with boolean"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with boolean"
);
}
SECTION
(
"string"
)
{
json
j_nonarray
(
json
::
value_t
::
string
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with string"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with string"
);
}
SECTION
(
"object"
)
{
json
j_nonarray
(
json
::
value_t
::
object
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with object"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with object"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with object"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with object"
);
}
SECTION
(
"number (integer)"
)
{
json
j_nonarray
(
json
::
value_t
::
number_integer
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
SECTION
(
"number (unsigned)"
)
{
json
j_nonarray
(
json
::
value_t
::
number_unsigned
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
SECTION
(
"number (floating-point)"
)
{
json
j_nonarray
(
json
::
value_t
::
number_float
);
const
json
j_nonarray_const
(
j_nonarray
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonarray
[
0
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_nonarray_const
[
0
],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_nonarray
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonarray_const
[
0
],
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
}
}
...
...
test/src/unit-element_access2.cpp
浏览文件 @
aa842b4a
...
...
@@ -447,106 +447,118 @@ TEST_CASE("element access 2")
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_NOTHROW
(
j_nonobject
[
"foo"
]);
CHECK_NOTHROW
(
j_nonobject2
[
json
::
object_t
::
key_type
(
"foo"
)]);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain
_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain
_error
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with null"
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type
_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type
_error
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"
[json.exception.type_error.305]
cannot use operator[] with null"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with null"
);
"
[json.exception.type_error.305]
cannot use operator[] with null"
);
}
SECTION
(
"boolean"
)
{
json
j_nonobject
(
json
::
value_t
::
boolean
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with boolean"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with boolean"
);
"[json.exception.type_error.305] cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with boolean"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with boolean"
);
"
[json.exception.type_error.305]
cannot use operator[] with boolean"
);
}
SECTION
(
"string"
)
{
json
j_nonobject
(
json
::
value_t
::
string
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with string"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with string"
);
"[json.exception.type_error.305] cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with string"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with string"
);
"
[json.exception.type_error.305]
cannot use operator[] with string"
);
}
SECTION
(
"array"
)
{
json
j_nonobject
(
json
::
value_t
::
array
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with array"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with array"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with array"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with array"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"[json.exception.type_error.305] cannot use operator[] with array"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with array"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with array"
);
"
[json.exception.type_error.305]
cannot use operator[] with array"
);
}
SECTION
(
"number (integer)"
)
{
json
j_nonobject
(
json
::
value_t
::
number_integer
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
SECTION
(
"number (unsigned)"
)
{
json
j_nonobject
(
json
::
value_t
::
number_unsigned
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
SECTION
(
"number (floating-point)"
)
{
json
j_nonobject
(
json
::
value_t
::
number_float
);
const
json
j_const_nonobject
(
j_nonobject
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
std
::
domain_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
std
::
domain_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
CHECK_THROWS_AS
(
j_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
"foo"
],
json
::
type_error
);
CHECK_THROWS_AS
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
json
::
type_error
);
CHECK_THROWS_WITH
(
j_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"cannot use operator[] with number"
);
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
"foo"
],
"[json.exception.type_error.305] cannot use operator[] with number"
);
CHECK_THROWS_WITH
(
j_const_nonobject
[
json
::
object_t
::
key_type
(
"foo"
)],
"cannot use operator[] with number"
);
"
[json.exception.type_error.305]
cannot use operator[] with number"
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录