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
1554baa0
Commit
1554baa0
authored
Jan 14, 2017
by
Théo DELRIEU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attempting to fix coverage. testing that reserve is called
parent
a9d5ae4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
test/src/unit-conversions.cpp
test/src/unit-conversions.cpp
+18
-0
No files found.
test/src/unit-conversions.cpp
View file @
1554baa0
...
...
@@ -160,12 +160,28 @@ TEST_CASE("value conversion")
{
std
::
forward_list
<
json
>
a
=
j
.
get
<
std
::
forward_list
<
json
>>
();
CHECK
(
json
(
a
)
==
j
);
CHECK_THROWS_AS
(
json
(
json
::
value_t
::
null
).
get
<
std
::
forward_list
<
json
>>
(),
std
::
logic_error
);
CHECK_THROWS_WITH
(
json
(
json
::
value_t
::
null
).
get
<
std
::
forward_list
<
json
>>
(),
"type must be array, but is null"
);
}
SECTION
(
"std::vector<json>"
)
{
std
::
vector
<
json
>
a
=
j
.
get
<
std
::
vector
<
json
>>
();
CHECK
(
json
(
a
)
==
j
);
CHECK_THROWS_AS
(
json
(
json
::
value_t
::
null
).
get
<
std
::
vector
<
json
>>
(),
std
::
logic_error
);
CHECK_THROWS_WITH
(
json
(
json
::
value_t
::
null
).
get
<
std
::
vector
<
json
>>
(),
"type must be array, but is null"
);
SECTION
(
"reserve is called on containers that supports it"
)
{
// making the call to from_json throw in order to check capacity
std
::
vector
<
float
>
v
;
CHECK_THROWS_AS
(
nlohmann
::
from_json
(
j
,
v
),
std
::
logic_error
);
CHECK
(
v
.
capacity
()
==
j
.
size
());
}
}
SECTION
(
"std::deque<json>"
)
...
...
@@ -184,6 +200,8 @@ TEST_CASE("value conversion")
CHECK_THROWS_AS
(
json
(
json
::
value_t
::
number_unsigned
).
get
<
json
::
array_t
>
(),
std
::
logic_error
);
CHECK_THROWS_AS
(
json
(
json
::
value_t
::
number_float
).
get
<
json
::
array_t
>
(),
std
::
logic_error
);
CHECK_THROWS_WITH
(
json
(
json
::
value_t
::
object
).
get
<
std
::
vector
<
int
>>
(),
"type must be array, but is object"
);
CHECK_THROWS_WITH
(
json
(
json
::
value_t
::
null
).
get
<
json
::
array_t
>
(),
"type must be array, but is null"
);
CHECK_THROWS_WITH
(
json
(
json
::
value_t
::
object
).
get
<
json
::
array_t
>
(),
...
...
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