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
861ee400
Unverified
Commit
861ee400
authored
Aug 14, 2018
by
Niels Lohmann
Committed by
GitHub
Aug 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1176 from grembo/develop
Fix unit tests that were silently skipped or crashed (depending on the compiler)
parents
3ce43253
05b27e83
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
33 deletions
+108
-33
unit-cbor.cpp
test/src/unit-cbor.cpp
+42
-12
unit-msgpack.cpp
test/src/unit-msgpack.cpp
+45
-12
unit-ubjson.cpp
test/src/unit-ubjson.cpp
+21
-9
No files found.
test/src/unit-cbor.cpp
View file @
861ee400
...
...
@@ -1660,6 +1660,21 @@ TEST_CASE("CBOR roundtrips", "[hide]")
{
SECTION
(
"input from flynn"
)
{
// most of these are exluded due to differences in key order (not a real problem)
auto
exclude_packed
=
std
::
set
<
std
::
string
>
{
"test/data/json.org/1.json"
,
"test/data/json.org/2.json"
,
"test/data/json.org/3.json"
,
"test/data/json.org/4.json"
,
"test/data/json.org/5.json"
,
"test/data/json_testsuite/sample.json"
,
// kills AppVeyor
"test/data/json_tests/pass1.json"
,
"test/data/regression/working_file.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_duplicated_key.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_long_strings.json"
,
};
for
(
std
::
string
filename
:
{
"test/data/json_nlohmann_tests/all_unicode.json"
,
...
...
@@ -1811,12 +1826,12 @@ TEST_CASE("CBOR roundtrips", "[hide]")
{
CAPTURE
(
filename
);
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
SECTION
(
"std::vector<uint8_t>"
)
SECTION
(
filename
+
": std::vector<uint8_t>"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse CBOR file
std
::
ifstream
f_cbor
(
filename
+
".cbor"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -1829,8 +1844,12 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
std::ifstream"
)
SECTION
(
filename
+
":
std::ifstream"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse CBOR file
std
::
ifstream
f_cbor
(
filename
+
".cbor"
,
std
::
ios
::
binary
);
json
j2
;
...
...
@@ -1840,8 +1859,12 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
uint8_t* and size"
)
SECTION
(
filename
+
":
uint8_t* and size"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse CBOR file
std
::
ifstream
f_cbor
(
filename
+
".cbor"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -1854,19 +1877,26 @@ TEST_CASE("CBOR roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
output to output adapters"
)
SECTION
(
filename
+
":
output to output adapters"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse CBOR file
std
::
ifstream
f_cbor
(
filename
+
".cbor"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
(
std
::
istreambuf_iterator
<
char
>
(
f_cbor
)),
std
::
istreambuf_iterator
<
char
>
());
SECTION
(
"std::vector<uint8_t>"
)
if
(
!
exclude_packed
.
count
(
filename
)
)
{
std
::
vector
<
uint8_t
>
vec
;
json
::
to_cbor
(
j1
,
vec
);
CHECK
(
vec
==
packed
);
SECTION
(
filename
+
": output adapters: std::vector<uint8_t>"
)
{
std
::
vector
<
uint8_t
>
vec
;
json
::
to_cbor
(
j1
,
vec
);
CHECK
(
vec
==
packed
);
}
}
}
}
...
...
test/src/unit-msgpack.cpp
View file @
861ee400
...
...
@@ -1349,6 +1349,24 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
{
SECTION
(
"input from msgpack-python"
)
{
// most of these are exluded due to differences in key order (not a real problem)
auto
exclude_packed
=
std
::
set
<
std
::
string
>
{
"test/data/json.org/1.json"
,
"test/data/json.org/2.json"
,
"test/data/json.org/3.json"
,
"test/data/json.org/4.json"
,
"test/data/json.org/5.json"
,
"test/data/json_testsuite/sample.json"
,
// kills AppVeyor
"test/data/json_tests/pass1.json"
,
"test/data/regression/working_file.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_basic.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_duplicated_key.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_long_strings.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_simple.json"
,
"test/data/nst_json_testsuite/test_parsing/y_object_string_unicode.json"
,
};
for
(
std
::
string
filename
:
{
"test/data/json_nlohmann_tests/all_unicode.json"
,
...
...
@@ -1500,12 +1518,12 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
{
CAPTURE
(
filename
);
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
SECTION
(
"std::vector<uint8_t>"
)
SECTION
(
filename
+
": std::vector<uint8_t>"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_msgpack
(
filename
+
".msgpack"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -1518,8 +1536,12 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
std::ifstream"
)
SECTION
(
filename
+
":
std::ifstream"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_msgpack
(
filename
+
".msgpack"
,
std
::
ios
::
binary
);
json
j2
;
...
...
@@ -1529,8 +1551,12 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
uint8_t* and size"
)
SECTION
(
filename
+
":
uint8_t* and size"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_msgpack
(
filename
+
".msgpack"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -1543,19 +1569,26 @@ TEST_CASE("MessagePack roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
output to output adapters"
)
SECTION
(
filename
+
":
output to output adapters"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_msgpack
(
filename
+
".msgpack"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
(
std
::
istreambuf_iterator
<
char
>
(
f_msgpack
)),
std
::
istreambuf_iterator
<
char
>
());
SECTION
(
"std::vector<uint8_t>"
)
if
(
!
exclude_packed
.
count
(
filename
)
)
{
std
::
vector
<
uint8_t
>
vec
;
json
::
to_msgpack
(
j1
,
vec
);
CHECK
(
vec
==
packed
);
SECTION
(
filename
+
": output adapters: std::vector<uint8_t>"
)
{
std
::
vector
<
uint8_t
>
vec
;
json
::
to_msgpack
(
j1
,
vec
);
CHECK
(
vec
==
packed
);
}
}
}
}
...
...
test/src/unit-ubjson.cpp
View file @
861ee400
...
...
@@ -2199,12 +2199,12 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
{
CAPTURE
(
filename
);
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
SECTION
(
"std::vector<uint8_t>"
)
SECTION
(
filename
+
": std::vector<uint8_t>"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_ubjson
(
filename
+
".ubjson"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -2217,8 +2217,12 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
std::ifstream"
)
SECTION
(
filename
+
":
std::ifstream"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_ubjson
(
filename
+
".ubjson"
,
std
::
ios
::
binary
);
json
j2
;
...
...
@@ -2228,8 +2232,12 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
uint8_t* and size"
)
SECTION
(
filename
+
":
uint8_t* and size"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_ubjson
(
filename
+
".ubjson"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
...
...
@@ -2242,15 +2250,19 @@ TEST_CASE("UBJSON roundtrips", "[hide]")
CHECK
(
j1
==
j2
);
}
SECTION
(
"
output to output adapters"
)
SECTION
(
filename
+
":
output to output adapters"
)
{
// parse JSON file
std
::
ifstream
f_json
(
filename
);
json
j1
=
json
::
parse
(
f_json
);
// parse MessagePack file
std
::
ifstream
f_ubjson
(
filename
+
".ubjson"
,
std
::
ios
::
binary
);
std
::
vector
<
uint8_t
>
packed
(
(
std
::
istreambuf_iterator
<
char
>
(
f_ubjson
)),
std
::
istreambuf_iterator
<
char
>
());
SECTION
(
"
std::vector<uint8_t>"
)
SECTION
(
filename
+
": output adapters:
std::vector<uint8_t>"
)
{
std
::
vector
<
uint8_t
>
vec
;
json
::
to_ubjson
(
j1
,
vec
);
...
...
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