Added test for conversion to string_view
This commit is contained in:
parent
53d8d57921
commit
c78dbc366c
1 changed files with 19 additions and 0 deletions
|
@ -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")
|
||||||
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")
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue