Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
8af49d4b
Unverified
Commit
8af49d4b
authored
Sep 30, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
removing compiler warnings #755
parent
1a66527d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
17 deletions
+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
No files found.
src/json.hpp
View file @
8af49d4b
...
@@ -62,7 +62,7 @@ SOFTWARE.
...
@@ -62,7 +62,7 @@ SOFTWARE.
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
#if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#endif
#elif defined(__GNUC__)
#elif defined(__GNUC__)
&& !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#endif
...
@@ -6320,7 +6320,7 @@ class serializer
...
@@ -6320,7 +6320,7 @@ class serializer
*/
*/
static
constexpr
std
::
size_t
bytes_following
(
const
uint8_t
u
)
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
:
((
192
<=
u
and
u
<=
223
)
?
1
:
((
224
<=
u
and
u
<=
239
)
?
2
:
((
224
<=
u
and
u
<=
239
)
?
2
:
((
240
<=
u
and
u
<=
247
)
?
3
:
std
::
string
::
npos
))));
:
((
240
<=
u
and
u
<=
247
)
?
3
:
std
::
string
::
npos
))));
...
@@ -6660,7 +6660,7 @@ class serializer
...
@@ -6660,7 +6660,7 @@ class serializer
return
;
return
;
}
}
const
bool
is_negative
=
x
<
0
;
const
auto
is_negative
=
std
::
signbit
(
x
)
;
std
::
size_t
i
=
0
;
std
::
size_t
i
=
0
;
// spare 1 byte for '\0'
// spare 1 byte for '\0'
...
@@ -9759,7 +9759,7 @@ class basic_json
...
@@ -9759,7 +9759,7 @@ class basic_json
,
"incompatible pointer type"
);
,
"incompatible pointer type"
);
// delegate the call to get_impl_ptr<>() const
// 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
View file @
8af49d4b
...
@@ -739,13 +739,13 @@ TEST_CASE("CBOR")
...
@@ -739,13 +739,13 @@ TEST_CASE("CBOR")
{
{
SECTION
(
"no byte follows"
)
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
})),
CHECK_THROWS_WITH
(
json
::
from_cbor
(
std
::
vector
<
uint8_t
>
({
0xf9
})),
"[json.exception.parse_error.110] parse error at 2: unexpected end of input"
);
"[json.exception.parse_error.110] parse error at 2: unexpected end of input"
);
}
}
SECTION
(
"only one byte follows"
)
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
})),
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"
);
"[json.exception.parse_error.110] parse error at 3: unexpected end of input"
);
}
}
...
...
test/src/unit-deserialization.cpp
View file @
8af49d4b
...
@@ -451,11 +451,11 @@ TEST_CASE("deserialization")
...
@@ -451,11 +451,11 @@ TEST_CASE("deserialization")
SECTION
(
"BOM only"
)
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
),
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"
);
"[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
)),
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"
);
"[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")
...
@@ -468,22 +468,22 @@ TEST_CASE("deserialization")
SECTION
(
"2 byte of BOM"
)
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
),
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"
);
"[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
)),
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"
);
"[json.exception.parse_error.101] parse error at 1: syntax error - unexpected end of input; expected '[', '{', or a literal"
);
}
}
SECTION
(
"1 byte of BOM"
)
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
),
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"
);
"[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
)),
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"
);
"[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")
...
@@ -504,9 +504,9 @@ TEST_CASE("deserialization")
CAPTURE
(
i2
);
CAPTURE
(
i2
);
std
::
string
s
=
""
;
std
::
string
s
=
""
;
s
.
push_back
(
bom
[
0
]
+
i0
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
0
]
+
i0
)
);
s
.
push_back
(
bom
[
1
]
+
i1
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
1
]
+
i1
)
);
s
.
push_back
(
bom
[
2
]
+
i2
);
s
.
push_back
(
static_cast
<
char
>
(
bom
[
2
]
+
i2
)
);
if
(
i0
==
0
and
i1
==
0
and
i2
==
0
)
if
(
i0
==
0
and
i1
==
0
and
i2
==
0
)
{
{
...
@@ -517,8 +517,8 @@ TEST_CASE("deserialization")
...
@@ -517,8 +517,8 @@ TEST_CASE("deserialization")
else
else
{
{
// any variation is an error
// any variation is an error
CHECK_THROWS_AS
(
json
::
parse
(
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
);
CHECK_THROWS_AS
(
json
::
parse
(
std
::
istringstream
(
s
+
"null"
)),
json
::
parse_error
&
);
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment