Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
畅游知识海洋
json
提交
8af49d4b
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,发现更多精彩内容 >>
未验证
提交
8af49d4b
编写于
9月 30, 2017
作者:
N
Niels Lohmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🚨
removing compiler warnings #755
上级
1a66527d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
17 deletion
+17
-17
src/json.hpp
src/json.hpp
+4
-4
test/src/unit-cbor.cpp
test/src/unit-cbor.cpp
+2
-2
test/src/unit-deserialization.cpp
test/src/unit-deserialization.cpp
+11
-11
未找到文件。
src/json.hpp
浏览文件 @
8af49d4b
...
...
@@ -62,7 +62,7 @@ SOFTWARE.
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#elif defined(__GNUC__)
#elif defined(__GNUC__)
&& !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
...
...
@@ -6320,7 +6320,7 @@ class serializer
*/
static
constexpr
std
::
size_t
bytes_following
(
const
uint8_t
u
)
{
return
((
0
<=
u
and
u
<=
127
)
?
0
return
((
u
<=
127
)
?
0
:
((
192
<=
u
and
u
<=
223
)
?
1
:
((
224
<=
u
and
u
<=
239
)
?
2
:
((
240
<=
u
and
u
<=
247
)
?
3
:
std
::
string
::
npos
))));
...
...
@@ -6660,7 +6660,7 @@ class serializer
return
;
}
const
bool
is_negative
=
x
<
0
;
const
auto
is_negative
=
std
::
signbit
(
x
)
;
std
::
size_t
i
=
0
;
// spare 1 byte for '\0'
...
...
@@ -9759,7 +9759,7 @@ class basic_json
,
"incompatible pointer type"
);
// delegate the call to get_impl_ptr<>() const
return
get_impl_ptr
(
static_cast
<
const
PointerType
>
(
nullptr
));
return
get_impl_ptr
(
static_cast
<
PointerType
>
(
nullptr
));
}
/*!
...
...
test/src/unit-cbor.cpp
浏览文件 @
8af49d4b
...
...
@@ -739,13 +739,13 @@ TEST_CASE("CBOR")
{
SECTION
(
"no byte follows"
)
{
CHECK_THROWS_AS
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
})),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
})),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
})),
"[json.exception.parse_error.110] parse error at 2: unexpected end of input"
);
}
SECTION
(
"only one byte follows"
)
{
CHECK_THROWS_AS
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
,
0x7c
})),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
,
0x7c
})),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
,
0x7c
})),
"[json.exception.parse_error.110] parse error at 3: unexpected end of input"
);
}
...
...
test/src/unit-deserialization.cpp
浏览文件 @
8af49d4b
...
...
@@ -451,11 +451,11 @@ TEST_CASE("deserialization")
SECTION
(
"BOM only"
)
{
CHECK_THROWS_AS
(
json
::
parse
(
bom
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
bom
),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
bom
),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
)),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
)),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
std
::
istringstream
(
bom
)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
}
...
...
@@ -468,22 +468,22 @@ TEST_CASE("deserialization")
SECTION
(
"2 byte of BOM"
)
{
CHECK_THROWS_AS
(
json
::
parse
(
bom
.
substr
(
0
,
2
)),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
bom
.
substr
(
0
,
2
)),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
bom
),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
.
substr
(
0
,
2
))),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
.
substr
(
0
,
2
))),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
std
::
istringstream
(
bom
)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
}
SECTION
(
"1 byte of BOM"
)
{
CHECK_THROWS_AS
(
json
::
parse
(
bom
.
substr
(
0
,
1
)),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
bom
.
substr
(
0
,
1
)),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
bom
),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
.
substr
(
0
,
1
))),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
bom
.
substr
(
0
,
1
))),
json
::
parse_error
&
);
CHECK_THROWS_WITH
(
json
::
parse
(
std
::
istringstream
(
bom
)),
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
}
...
...
@@ -504,9 +504,9 @@ TEST_CASE("deserialization")
CAPTURE
(
i2
);
std
::
string
s
=
""
;
s
.
push_back
(
bom
[
0
]
+
i0
);
s
.
push_back
(
bom
[
1
]
+
i1
);
s
.
push_back
(
bom
[
2
]
+
i2
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
0
]
+
i0
)
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
1
]
+
i1
)
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
2
]
+
i2
)
);
if
(
i0
==
0
and
i1
==
0
and
i2
==
0
)
{
...
...
@@ -517,8 +517,8 @@ TEST_CASE("deserialization")
else
{
// any variation is an error
CHECK_THROWS_AS
(
json
::
parse
(
s
+
"null"
),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
s
+
"null"
)),
json
::
parse_error
);
CHECK_THROWS_AS
(
json
::
parse
(
s
+
"null"
),
json
::
parse_error
&
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
s
+
"null"
)),
json
::
parse_error
&
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录