mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 19:42:12 +02:00
This commit is contained in:
@ -24,7 +24,7 @@ TEST_CASE("JsonVariant::as()") {
|
||||
|
||||
SECTION("DoubleAsString") {
|
||||
JsonVariant variant = 4.2;
|
||||
REQUIRE(std::string("4.20") == variant.as<std::string>());
|
||||
REQUIRE(std::string("4.2") == variant.as<std::string>());
|
||||
}
|
||||
|
||||
SECTION("DoubleAsLong") {
|
||||
|
@ -50,10 +50,10 @@ void checkIsFloat(JsonVariant var) {
|
||||
void checkIsInteger(JsonVariant var) {
|
||||
REQUIRE(var.is<long>());
|
||||
REQUIRE(var.is<int>());
|
||||
REQUIRE(var.is<float>());
|
||||
REQUIRE(var.is<double>());
|
||||
|
||||
REQUIRE_FALSE(var.is<bool>());
|
||||
REQUIRE_FALSE(var.is<double>());
|
||||
REQUIRE_FALSE(var.is<float>());
|
||||
REQUIRE_FALSE(var.is<const char*>());
|
||||
REQUIRE_FALSE(var.is<JsonArray>());
|
||||
REQUIRE_FALSE(var.is<JsonObject>());
|
||||
|
@ -29,48 +29,8 @@ TEST_CASE("JsonVariant::printTo()") {
|
||||
check("hello", "\"hello\"");
|
||||
}
|
||||
|
||||
SECTION("DoubleZero") {
|
||||
check(0.0, "0.00");
|
||||
}
|
||||
|
||||
SECTION("DoubleDefaultDigits") {
|
||||
check(3.14159265358979323846, "3.14");
|
||||
}
|
||||
|
||||
SECTION("DoubleFourDigits") {
|
||||
check(JsonVariant(3.14159265358979323846, 4), "3.1416");
|
||||
}
|
||||
|
||||
SECTION("Infinity") {
|
||||
check(std::numeric_limits<double>::infinity(), "Infinity");
|
||||
}
|
||||
|
||||
SECTION("MinusInfinity") {
|
||||
check(-std::numeric_limits<double>::infinity(), "-Infinity");
|
||||
}
|
||||
|
||||
SECTION("SignalingNaN") {
|
||||
check(std::numeric_limits<double>::signaling_NaN(), "NaN");
|
||||
}
|
||||
|
||||
SECTION("QuietNaN") {
|
||||
check(std::numeric_limits<double>::quiet_NaN(), "NaN");
|
||||
}
|
||||
|
||||
SECTION("VeryBigPositiveDouble") {
|
||||
check(JsonVariant(3.14159265358979323846e42, 4), "3.1416e42");
|
||||
}
|
||||
|
||||
SECTION("VeryBigNegativeDouble") {
|
||||
check(JsonVariant(-3.14159265358979323846e42, 4), "-3.1416e42");
|
||||
}
|
||||
|
||||
SECTION("VerySmallPositiveDouble") {
|
||||
check(JsonVariant(3.14159265358979323846e-42, 4), "3.1416e-42");
|
||||
}
|
||||
|
||||
SECTION("VerySmallNegativeDouble") {
|
||||
check(JsonVariant(-3.14159265358979323846e-42, 4), "-3.1416e-42");
|
||||
SECTION("Double") {
|
||||
check(3.1415927, "3.1415927");
|
||||
}
|
||||
|
||||
SECTION("Integer") {
|
||||
|
Reference in New Issue
Block a user