mirror of
https://github.com/nlohmann/json.git
synced 2026-02-11 12:22:33 +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:
@@ -1011,21 +1011,21 @@ TEST_CASE("CBOR")
|
||||
SECTION("0 (0 00000 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == 0.0);
|
||||
}
|
||||
|
||||
SECTION("-0 (1 00000 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x80, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == -0.0);
|
||||
}
|
||||
|
||||
SECTION("2**-24 (0 00000 0000000001)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x00, 0x01}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == std::pow(2.0, -24.0));
|
||||
}
|
||||
}
|
||||
@@ -1035,7 +1035,7 @@ TEST_CASE("CBOR")
|
||||
SECTION("infinity (0 11111 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == std::numeric_limits<json::number_float_t>::infinity());
|
||||
CHECK(j.dump() == "null");
|
||||
}
|
||||
@@ -1043,7 +1043,7 @@ TEST_CASE("CBOR")
|
||||
SECTION("-infinity (1 11111 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xfc, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == -std::numeric_limits<json::number_float_t>::infinity());
|
||||
CHECK(j.dump() == "null");
|
||||
}
|
||||
@@ -1054,21 +1054,21 @@ TEST_CASE("CBOR")
|
||||
SECTION("1 (0 01111 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x3c, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == 1);
|
||||
}
|
||||
|
||||
SECTION("-2 (1 10000 0000000000)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0xc0, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == -2);
|
||||
}
|
||||
|
||||
SECTION("65504 (0 11110 1111111111)")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7b, 0xff}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(d == 65504);
|
||||
}
|
||||
}
|
||||
@@ -1076,7 +1076,7 @@ TEST_CASE("CBOR")
|
||||
SECTION("infinity")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7c, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(!std::isfinite(d));
|
||||
CHECK(j.dump() == "null");
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ TEST_CASE("CBOR")
|
||||
SECTION("NaN")
|
||||
{
|
||||
json j = json::from_cbor(std::vector<uint8_t>({0xf9, 0x7e, 0x00}));
|
||||
json::number_float_t d = j;
|
||||
json::number_float_t d{j};
|
||||
CHECK(std::isnan(d));
|
||||
CHECK(j.dump() == "null");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user