mirror of
https://github.com/nlohmann/json.git
synced 2026-02-15 13:42:18 +00:00
add a switch to enable implicit conversions (defaults to true)
wrap implicit conversions tests around the JSON_USE_IMPLICIT_CONVERSIONS macro
This commit is contained in:
@@ -174,9 +174,9 @@ TEST_CASE("README" * doctest::skip())
|
||||
}
|
||||
|
||||
// getter/setter
|
||||
const std::string tmp = j[0];
|
||||
const auto tmp = j[0].get<std::string>();
|
||||
j[1] = 42;
|
||||
bool foo = j.at(2);
|
||||
bool foo{j.at(2)};
|
||||
CHECK(foo == true);
|
||||
|
||||
// other stuff
|
||||
@@ -258,18 +258,18 @@ TEST_CASE("README" * doctest::skip())
|
||||
// strings
|
||||
std::string s1 = "Hello, world!";
|
||||
json js = s1;
|
||||
std::string s2 = js;
|
||||
auto s2 = js.get<std::string>();
|
||||
|
||||
// Booleans
|
||||
bool b1 = true;
|
||||
json jb = b1;
|
||||
bool b2 = jb;
|
||||
bool b2{jb};
|
||||
CHECK(b2 == true);
|
||||
|
||||
// numbers
|
||||
int i = 42;
|
||||
json jn = i;
|
||||
double f = jn;
|
||||
double f{jn};
|
||||
CHECK(f == 42);
|
||||
|
||||
// etc.
|
||||
|
||||
Reference in New Issue
Block a user