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
c78dbc36
Commit
c78dbc36
authored
7 years ago
by
Guillaume Racicot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for conversion to string_view
parent
53d8d579
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
test/src/unit-conversions.cpp
test/src/unit-conversions.cpp
+19
-0
No files found.
test/src/unit-conversions.cpp
View file @
c78dbc36
...
@@ -39,6 +39,10 @@ using nlohmann::json;
...
@@ -39,6 +39,10 @@ using nlohmann::json;
#include <unordered_set>
#include <unordered_set>
#include <valarray>
#include <valarray>
#if defined(JSON_HAS_CPP_17)
#include <string_view>
#endif
TEST_CASE
(
"value conversion"
)
TEST_CASE
(
"value conversion"
)
{
{
SECTION
(
"get an object (explicit)"
)
SECTION
(
"get an object (explicit)"
)
...
@@ -292,6 +296,13 @@ TEST_CASE("value conversion")
...
@@ -292,6 +296,13 @@ TEST_CASE("value conversion")
std
::
string
s
=
j
.
get
<
std
::
string
>
();
std
::
string
s
=
j
.
get
<
std
::
string
>
();
CHECK
(
json
(
s
)
==
j
);
CHECK
(
json
(
s
)
==
j
);
}
}
#if defined(JSON_HAS_CPP_17)
SECTION
(
"std::string_view"
)
{
std
::
string_view
s
=
j
.
get
<
std
::
string_view
>
();
CHECK
(
json
(
s
)
==
j
);
}
#endif
SECTION
(
"exception in case of a non-string type"
)
SECTION
(
"exception in case of a non-string type"
)
{
{
...
@@ -331,6 +342,14 @@ TEST_CASE("value conversion")
...
@@ -331,6 +342,14 @@ TEST_CASE("value conversion")
CHECK
(
json
(
s
)
==
j
);
CHECK
(
json
(
s
)
==
j
);
}
}
#if defined(JSON_HAS_CPP_17)
SECTION
(
"std::string_view"
)
{
std
::
string_view
s
=
j
;
CHECK
(
json
(
s
)
==
j
);
}
#endif
SECTION
(
"std::string"
)
SECTION
(
"std::string"
)
{
{
std
::
string
s
=
j
;
std
::
string
s
=
j
;
...
...
This diff is collapsed.
Click to expand it.
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