Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
d53ef950
Unverified
Commit
d53ef950
authored
Jul 22, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
fixed some warnings
parent
c7a69ae0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
json.hpp
src/json.hpp
+2
-2
unit-convenience.cpp
test/src/unit-convenience.cpp
+9
-10
No files found.
src/json.hpp
View file @
d53ef950
...
@@ -6644,7 +6644,7 @@ class serializer
...
@@ -6644,7 +6644,7 @@ class serializer
{
{
if
(
ensure_ascii
and
(
s
[
i
]
&
0x80
or
s
[
i
]
==
0x7F
))
if
(
ensure_ascii
and
(
s
[
i
]
&
0x80
or
s
[
i
]
==
0x7F
))
{
{
const
auto
bytes
=
bytes_following
(
s
[
i
]
&
0xFF
);
const
auto
bytes
=
bytes_following
(
s
tatic_cast
<
uint8_t
>
(
s
[
i
])
);
if
(
bytes
==
std
::
string
::
npos
)
if
(
bytes
==
std
::
string
::
npos
)
{
{
// invalid characters are treated as is, so no
// invalid characters are treated as is, so no
...
@@ -6821,7 +6821,7 @@ class serializer
...
@@ -6821,7 +6821,7 @@ class serializer
if
((
0x00
<=
s
[
i
]
and
s
[
i
]
<=
0x1F
)
or
if
((
0x00
<=
s
[
i
]
and
s
[
i
]
<=
0x1F
)
or
(
ensure_ascii
and
(
s
[
i
]
&
0x80
or
s
[
i
]
==
0x7F
)))
(
ensure_ascii
and
(
s
[
i
]
&
0x80
or
s
[
i
]
==
0x7F
)))
{
{
const
auto
bytes
=
bytes_following
(
s
[
i
]
&
0xFF
);
const
auto
bytes
=
bytes_following
(
s
tatic_cast
<
uint8_t
>
(
s
[
i
])
);
if
(
bytes
==
std
::
string
::
npos
)
if
(
bytes
==
std
::
string
::
npos
)
{
{
// copy invalid character as is
// copy invalid character as is
...
...
test/src/unit-convenience.cpp
View file @
d53ef950
...
@@ -32,6 +32,15 @@ SOFTWARE.
...
@@ -32,6 +32,15 @@ SOFTWARE.
#include "json.hpp"
#include "json.hpp"
using
nlohmann
::
json
;
using
nlohmann
::
json
;
void
check_escaped
(
const
char
*
original
,
const
char
*
escaped
,
const
bool
ensure_ascii
=
false
);
void
check_escaped
(
const
char
*
original
,
const
char
*
escaped
,
const
bool
ensure_ascii
)
{
std
::
stringstream
ss
;
json
::
serializer
s
(
nlohmann
::
detail
::
output_adapter_factory
<
char
>::
create
(
ss
),
' '
);
s
.
dump_escaped
(
original
,
ensure_ascii
);
CHECK
(
ss
.
str
()
==
escaped
);
}
TEST_CASE
(
"convenience functions"
)
TEST_CASE
(
"convenience functions"
)
{
{
SECTION
(
"type name as string"
)
SECTION
(
"type name as string"
)
...
@@ -49,16 +58,6 @@ TEST_CASE("convenience functions")
...
@@ -49,16 +58,6 @@ TEST_CASE("convenience functions")
SECTION
(
"string escape"
)
SECTION
(
"string escape"
)
{
{
const
auto
check_escaped
=
[](
const
char
*
original
,
const
char
*
escaped
,
const
bool
ensure_ascii
=
false
)
{
std
::
stringstream
ss
;
json
::
serializer
s
(
nlohmann
::
detail
::
output_adapter_factory
<
char
>::
create
(
ss
),
' '
);
s
.
dump_escaped
(
original
,
ensure_ascii
);
CHECK
(
ss
.
str
()
==
escaped
);
};
check_escaped
(
"
\"
"
,
"
\\\"
"
);
check_escaped
(
"
\"
"
,
"
\\\"
"
);
check_escaped
(
"
\\
"
,
"
\\\\
"
);
check_escaped
(
"
\\
"
,
"
\\\\
"
);
check_escaped
(
"
\b
"
,
"
\\
b"
);
check_escaped
(
"
\b
"
,
"
\\
b"
);
...
...
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