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
dfe53c36
Unverified
Commit
dfe53c36
authored
Nov 03, 2019
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fix UBSAN warnings
parent
0db1692f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
25 deletions
+30
-25
test/src/unit-bson.cpp
test/src/unit-bson.cpp
+2
-3
test/src/unit-cbor.cpp
test/src/unit-cbor.cpp
+1
-1
test/src/unit-msgpack.cpp
test/src/unit-msgpack.cpp
+1
-1
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+26
-20
No files found.
test/src/unit-bson.cpp
View file @
dfe53c36
...
...
@@ -584,10 +584,9 @@ TEST_CASE("BSON input/output_adapters")
{
SECTION
(
"std::ostringstream"
)
{
std
::
ostringstream
ss
;
std
::
basic_ostringstream
<
std
::
uint8_t
>
ss
;
json
::
to_bson
(
json_representation
,
ss
);
std
::
istringstream
iss
(
ss
.
str
());
json
j3
=
json
::
from_bson
(
iss
);
json
j3
=
json
::
from_bson
(
ss
.
str
());
CHECK
(
json_representation
==
j3
);
}
...
...
test/src/unit-cbor.cpp
View file @
dfe53c36
...
...
@@ -1580,7 +1580,7 @@ TEST_CASE("single CBOR roundtrip")
{
SECTION
(
"std::ostringstream"
)
{
std
::
ostringstream
ss
;
std
::
basic_ostringstream
<
std
::
uint8_t
>
ss
;
json
::
to_cbor
(
j1
,
ss
);
json
j3
=
json
::
from_cbor
(
ss
.
str
());
CHECK
(
j1
==
j3
);
...
...
test/src/unit-msgpack.cpp
View file @
dfe53c36
...
...
@@ -1334,7 +1334,7 @@ TEST_CASE("single MessagePack roundtrip")
{
SECTION
(
"std::ostringstream"
)
{
std
::
ostringstream
ss
;
std
::
basic_ostringstream
<
std
::
uint8_t
>
ss
;
json
::
to_msgpack
(
j1
,
ss
);
json
j3
=
json
::
from_msgpack
(
ss
.
str
());
CHECK
(
j1
==
j3
);
...
...
test/src/unit-regression.cpp
View file @
dfe53c36
...
...
@@ -1749,31 +1749,37 @@ TEST_CASE("regression tests")
{
SECTION
(
"a bunch of -1, ensure_ascii=true"
)
{
const
auto
length
=
300
;
json
dump_test
;
std
::
vector
<
char
>
data
(
300
,
-
1
);
std
::
vector
<
std
::
string
>
vec_string
(
300
,
"
\\
ufffd"
);
std
::
string
s
{
data
.
data
(),
data
.
size
()};
dump_test
[
"1"
]
=
s
;
std
::
ostringstream
os
;
os
<<
"{
\"
1
\"
:
\"
"
;
std
::
copy
(
vec_string
.
begin
(),
vec_string
.
end
(),
std
::
ostream_iterator
<
std
::
string
>
(
os
));
os
<<
"
\"
}"
;
s
=
dump_test
.
dump
(
-
1
,
' '
,
true
,
nlohmann
::
json
::
error_handler_t
::
replace
);
CHECK
(
s
==
os
.
str
());
dump_test
[
"1"
]
=
std
::
string
(
length
,
-
1
);
std
::
string
expected
=
"{
\"
1
\"
:
\"
"
;
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
expected
+=
"
\\
ufffd"
;
}
expected
+=
"
\"
}"
;
auto
s
=
dump_test
.
dump
(
-
1
,
' '
,
true
,
nlohmann
::
json
::
error_handler_t
::
replace
);
CHECK
(
s
==
expected
);
}
SECTION
(
"a bunch of -2, ensure_ascii=false"
)
{
const
auto
length
=
500
;
json
dump_test
;
std
::
vector
<
char
>
data
(
500
,
-
2
);
std
::
vector
<
std
::
string
>
vec_string
(
500
,
"
\xEF\xBF\xBD
"
);
std
::
string
s
{
data
.
data
(),
data
.
size
()};
dump_test
[
"1"
]
=
s
;
std
::
ostringstream
os
;
os
<<
"{
\"
1
\"
:
\"
"
;
std
::
copy
(
vec_string
.
begin
(),
vec_string
.
end
(),
std
::
ostream_iterator
<
std
::
string
>
(
os
));
os
<<
"
\"
}"
;
s
=
dump_test
.
dump
(
-
1
,
' '
,
false
,
nlohmann
::
json
::
error_handler_t
::
replace
);
CHECK
(
s
==
os
.
str
());
dump_test
[
"1"
]
=
std
::
string
(
length
,
-
2
);
std
::
string
expected
=
"{
\"
1
\"
:
\"
"
;
for
(
int
i
=
0
;
i
<
length
;
++
i
)
{
expected
+=
"
\xEF\xBF\xBD
"
;
}
expected
+=
"
\"
}"
;
auto
s
=
dump_test
.
dump
(
-
1
,
' '
,
false
,
nlohmann
::
json
::
error_handler_t
::
replace
);
CHECK
(
s
==
expected
);
}
SECTION
(
"test case in issue #1445"
)
{
...
...
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