Revert "Merge branch 'master' of https://github.com/1technophile/OpenMQTTGateway"
This reverts commita70c33a68e, reversing changes made tof515f9c03a.
This commit is contained in:
1 parent
a70c33a68e
commit
be5d61993d
220 files changed
+29
-26968
No files matched your search
@@ -1,13 +0,0 @@
|
||||
# ArduinoJson - arduinojson.org
|
||||
# Copyright Benoit Blanchon 2014-2018
|
||||
# MIT License
|
||||
|
||||
add_executable(PolyfillsTests
|
||||
isFloat.cpp
|
||||
isInteger.cpp
|
||||
parseFloat.cpp
|
||||
parseInteger.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(PolyfillsTests catch)
|
||||
add_test(Polyfills PolyfillsTests)
|
||||
@@ -1,76 +0,0 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Polyfills/isFloat.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
TEST_CASE("isFloat()") {
|
||||
SECTION("Input is NULL") {
|
||||
REQUIRE(isFloat(NULL) == false);
|
||||
}
|
||||
|
||||
SECTION("NoExponent") {
|
||||
REQUIRE(isFloat("3.14"));
|
||||
REQUIRE(isFloat("-3.14"));
|
||||
REQUIRE(isFloat("+3.14"));
|
||||
}
|
||||
|
||||
SECTION("IntegralPartMissing") {
|
||||
REQUIRE(isFloat(".14"));
|
||||
REQUIRE(isFloat("-.14"));
|
||||
REQUIRE(isFloat("+.14"));
|
||||
}
|
||||
|
||||
SECTION("FractionalPartMissing") {
|
||||
REQUIRE(isFloat("3."));
|
||||
REQUIRE(isFloat("-3.e14"));
|
||||
REQUIRE(isFloat("+3.e-14"));
|
||||
}
|
||||
|
||||
SECTION("NoDot") {
|
||||
REQUIRE(isFloat("3e14"));
|
||||
REQUIRE(isFloat("3e-14"));
|
||||
REQUIRE(isFloat("3e+14"));
|
||||
}
|
||||
|
||||
SECTION("Integer") {
|
||||
REQUIRE(isFloat("14"));
|
||||
REQUIRE(isFloat("-14"));
|
||||
REQUIRE(isFloat("+14"));
|
||||
}
|
||||
|
||||
SECTION("ExponentMissing") {
|
||||
REQUIRE_FALSE(isFloat("3.14e"));
|
||||
REQUIRE_FALSE(isFloat("3.14e-"));
|
||||
REQUIRE_FALSE(isFloat("3.14e+"));
|
||||
}
|
||||
|
||||
SECTION("JustASign") {
|
||||
REQUIRE_FALSE(isFloat("-"));
|
||||
REQUIRE_FALSE(isFloat("+"));
|
||||
}
|
||||
|
||||
SECTION("Empty") {
|
||||
REQUIRE_FALSE(isFloat(""));
|
||||
}
|
||||
|
||||
SECTION("NaN") {
|
||||
REQUIRE(isFloat("NaN"));
|
||||
REQUIRE_FALSE(isFloat("n"));
|
||||
REQUIRE_FALSE(isFloat("N"));
|
||||
REQUIRE_FALSE(isFloat("nan"));
|
||||
REQUIRE_FALSE(isFloat("-NaN"));
|
||||
REQUIRE_FALSE(isFloat("+NaN"));
|
||||
}
|
||||
|
||||
SECTION("Infinity") {
|
||||
REQUIRE(isFloat("Infinity"));
|
||||
REQUIRE(isFloat("+Infinity"));
|
||||
REQUIRE(isFloat("-Infinity"));
|
||||
REQUIRE_FALSE(isFloat("infinity"));
|
||||
REQUIRE_FALSE(isFloat("Inf"));
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Polyfills/isInteger.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
TEST_CASE("isInteger()") {
|
||||
SECTION("Null") {
|
||||
REQUIRE_FALSE(isInteger(NULL));
|
||||
}
|
||||
|
||||
SECTION("FloatNotInteger") {
|
||||
REQUIRE_FALSE(isInteger("3.14"));
|
||||
REQUIRE_FALSE(isInteger("-3.14"));
|
||||
REQUIRE_FALSE(isInteger("+3.14"));
|
||||
}
|
||||
|
||||
SECTION("Spaces") {
|
||||
REQUIRE_FALSE(isInteger("42 "));
|
||||
REQUIRE_FALSE(isInteger(" 42"));
|
||||
}
|
||||
|
||||
SECTION("Valid") {
|
||||
REQUIRE(isInteger("42"));
|
||||
REQUIRE(isInteger("-42"));
|
||||
REQUIRE(isInteger("+42"));
|
||||
}
|
||||
|
||||
SECTION("ExtraSign") {
|
||||
REQUIRE_FALSE(isInteger("--42"));
|
||||
REQUIRE_FALSE(isInteger("++42"));
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Polyfills/parseFloat.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
template <typename T>
|
||||
void check(const char* input, T expected) {
|
||||
CAPTURE(input);
|
||||
REQUIRE(parseFloat<T>(input) == Approx(expected));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void checkNaN(const char* input) {
|
||||
CAPTURE(input);
|
||||
T result = parseFloat<T>(input);
|
||||
REQUIRE(result != result);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void checkInf(const char* input, bool negative) {
|
||||
CAPTURE(input);
|
||||
T x = parseFloat<T>(input);
|
||||
if (negative)
|
||||
REQUIRE(x < 0);
|
||||
else
|
||||
REQUIRE(x > 0);
|
||||
REQUIRE(x == x); // not a NaN
|
||||
REQUIRE(x * 2 == x); // a property of infinity
|
||||
}
|
||||
|
||||
TEST_CASE("parseFloat<float>()") {
|
||||
SECTION("Null") {
|
||||
check<float>(NULL, 0);
|
||||
}
|
||||
|
||||
SECTION("Float_Short_NoExponent") {
|
||||
check<float>("3.14", 3.14f);
|
||||
check<float>("-3.14", -3.14f);
|
||||
check<float>("+3.14", +3.14f);
|
||||
}
|
||||
|
||||
SECTION("Short_NoDot") {
|
||||
check<float>("1E+38", 1E+38f);
|
||||
check<float>("-1E+38", -1E+38f);
|
||||
check<float>("+1E-38", +1E-38f);
|
||||
check<float>("+1e+38", +1e+38f);
|
||||
check<float>("-1e-38", -1e-38f);
|
||||
}
|
||||
|
||||
SECTION("Max") {
|
||||
check<float>("340.2823e+36", 3.402823e+38f);
|
||||
check<float>("34.02823e+37", 3.402823e+38f);
|
||||
check<float>("3.402823e+38", 3.402823e+38f);
|
||||
check<float>("0.3402823e+39", 3.402823e+38f);
|
||||
check<float>("0.03402823e+40", 3.402823e+38f);
|
||||
check<float>("0.003402823e+41", 3.402823e+38f);
|
||||
}
|
||||
|
||||
SECTION("VeryLong") {
|
||||
check<float>("0.00000000000000000000000000000001", 1e-32f);
|
||||
check<float>("100000000000000000000000000000000.0", 1e+32f);
|
||||
check<float>(
|
||||
"100000000000000000000000000000000.00000000000000000000000000000",
|
||||
1e+32f);
|
||||
}
|
||||
|
||||
SECTION("MantissaTooLongToFit") {
|
||||
check<float>("0.340282346638528861111111111111", 0.34028234663852886f);
|
||||
check<float>("34028234663852886.11111111111111", 34028234663852886.0f);
|
||||
check<float>("34028234.66385288611111111111111", 34028234.663852886f);
|
||||
|
||||
check<float>("-0.340282346638528861111111111111", -0.34028234663852886f);
|
||||
check<float>("-34028234663852886.11111111111111", -34028234663852886.0f);
|
||||
check<float>("-34028234.66385288611111111111111", -34028234.663852886f);
|
||||
}
|
||||
|
||||
SECTION("ExponentTooBig") {
|
||||
checkInf<float>("1e39", false);
|
||||
checkInf<float>("-1e39", true);
|
||||
checkInf<float>("1e255", false);
|
||||
check<float>("1e-255", 0.0f);
|
||||
}
|
||||
|
||||
SECTION("NaN") {
|
||||
checkNaN<float>("NaN");
|
||||
checkNaN<float>("nan");
|
||||
}
|
||||
|
||||
SECTION("Infinity") {
|
||||
checkInf<float>("Infinity", false);
|
||||
checkInf<float>("+Infinity", false);
|
||||
checkInf<float>("-Infinity", true);
|
||||
checkInf<float>("inf", false);
|
||||
checkInf<float>("+inf", false);
|
||||
checkInf<float>("-inf", true);
|
||||
}
|
||||
|
||||
SECTION("Boolean") {
|
||||
check<float>("false", 0.0f);
|
||||
check<float>("true", 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("parseFloat<double>()") {
|
||||
SECTION("Null") {
|
||||
check<double>(NULL, 0);
|
||||
}
|
||||
|
||||
SECTION("Short_NoExponent") {
|
||||
check<double>("3.14", 3.14);
|
||||
check<double>("-3.14", -3.14);
|
||||
check<double>("+3.14", +3.14);
|
||||
}
|
||||
|
||||
SECTION("Short_NoDot") {
|
||||
check<double>("1E+308", 1E+308);
|
||||
check<double>("-1E+308", -1E+308);
|
||||
check<double>("+1E-308", +1E-308);
|
||||
check<double>("+1e+308", +1e+308);
|
||||
check<double>("-1e-308", -1e-308);
|
||||
}
|
||||
|
||||
SECTION("Max") {
|
||||
check<double>(".017976931348623147e+310", 1.7976931348623147e+308);
|
||||
check<double>(".17976931348623147e+309", 1.7976931348623147e+308);
|
||||
check<double>("1.7976931348623147e+308", 1.7976931348623147e+308);
|
||||
check<double>("17.976931348623147e+307", 1.7976931348623147e+308);
|
||||
check<double>("179.76931348623147e+306", 1.7976931348623147e+308);
|
||||
}
|
||||
|
||||
SECTION("Min") {
|
||||
check<double>(".022250738585072014e-306", 2.2250738585072014e-308);
|
||||
check<double>(".22250738585072014e-307", 2.2250738585072014e-308);
|
||||
check<double>("2.2250738585072014e-308", 2.2250738585072014e-308);
|
||||
check<double>("22.250738585072014e-309", 2.2250738585072014e-308);
|
||||
check<double>("222.50738585072014e-310", 2.2250738585072014e-308);
|
||||
}
|
||||
|
||||
SECTION("VeryLong") {
|
||||
check<double>("0.00000000000000000000000000000001", 1e-32);
|
||||
check<double>("100000000000000000000000000000000.0", 1e+32);
|
||||
check<double>(
|
||||
"100000000000000000000000000000000.00000000000000000000000000000",
|
||||
1e+32);
|
||||
}
|
||||
|
||||
SECTION("MantissaTooLongToFit") {
|
||||
check<double>("0.179769313486231571111111111111", 0.17976931348623157);
|
||||
check<double>("17976931348623157.11111111111111", 17976931348623157.0);
|
||||
check<double>("1797693.134862315711111111111111", 1797693.1348623157);
|
||||
|
||||
check<double>("-0.179769313486231571111111111111", -0.17976931348623157);
|
||||
check<double>("-17976931348623157.11111111111111", -17976931348623157.0);
|
||||
check<double>("-1797693.134862315711111111111111", -1797693.1348623157);
|
||||
}
|
||||
|
||||
SECTION("ExponentTooBig") {
|
||||
checkInf<double>("1e309", false);
|
||||
checkInf<double>("-1e309", true);
|
||||
checkInf<double>("1e65535", false);
|
||||
check<double>("1e-65535", 0.0);
|
||||
}
|
||||
|
||||
SECTION("NaN") {
|
||||
checkNaN<double>("NaN");
|
||||
checkNaN<double>("nan");
|
||||
}
|
||||
|
||||
SECTION("Boolean") {
|
||||
check<double>("false", 0.0);
|
||||
check<double>("true", 1.0);
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
// ArduinoJson - arduinojson.org
|
||||
// Copyright Benoit Blanchon 2014-2018
|
||||
// MIT License
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ArduinoJson/Polyfills/parseInteger.hpp>
|
||||
#include <catch.hpp>
|
||||
|
||||
using namespace ArduinoJson::Internals;
|
||||
|
||||
template <typename T>
|
||||
void check(const char* input, T expected) {
|
||||
CAPTURE(input);
|
||||
T actual = parseInteger<T>(input);
|
||||
REQUIRE(expected == actual);
|
||||
}
|
||||
|
||||
TEST_CASE("parseInteger<int8_t>()") {
|
||||
check<int8_t>("-128", -128);
|
||||
check<int8_t>("127", 127);
|
||||
check<int8_t>("+127", 127);
|
||||
check<int8_t>("3.14", 3);
|
||||
check<int8_t>("x42", 0);
|
||||
check<int8_t>("128", -128);
|
||||
check<int8_t>("-129", 127);
|
||||
check<int8_t>(NULL, 0);
|
||||
check<int8_t>("true", 1);
|
||||
check<int8_t>("false", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("parseInteger<int16_t>()") {
|
||||
check<int16_t>("-32768", -32768);
|
||||
check<int16_t>("32767", 32767);
|
||||
check<int16_t>("+32767", 32767);
|
||||
check<int16_t>("3.14", 3);
|
||||
check<int16_t>("x42", 0);
|
||||
check<int16_t>("-32769", 32767);
|
||||
check<int16_t>("32768", -32768);
|
||||
check<int16_t>(NULL, 0);
|
||||
check<int16_t>("true", 1);
|
||||
check<int16_t>("false", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("parseInteger<int32_t>()") {
|
||||
check<int32_t>("-2147483648", (-2147483647 - 1));
|
||||
check<int32_t>("2147483647", 2147483647);
|
||||
check<int32_t>("+2147483647", 2147483647);
|
||||
check<int32_t>("3.14", 3);
|
||||
check<int32_t>("x42", 0);
|
||||
check<int32_t>("-2147483649", 2147483647);
|
||||
check<int32_t>("2147483648", (-2147483647 - 1));
|
||||
check<int32_t>("true", 1);
|
||||
check<int32_t>("false", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("parseInteger<uint8_t>()") {
|
||||
check<uint8_t>("0", 0);
|
||||
check<uint8_t>("255", 255);
|
||||
check<uint8_t>("+255", 255);
|
||||
check<uint8_t>("3.14", 3);
|
||||
check<uint8_t>("x42", 0);
|
||||
check<uint8_t>("-1", 255);
|
||||
check<uint8_t>("256", 0);
|
||||
check<uint8_t>("true", 1);
|
||||
check<uint8_t>("false", 0);
|
||||
}
|
||||
|
||||
TEST_CASE("parseInteger<uint16_t>()") {
|
||||
check<uint16_t>("0", 0);
|
||||
check<uint16_t>("65535", 65535);
|
||||
check<uint16_t>("+65535", 65535);
|
||||
check<uint16_t>("3.14", 3);
|
||||
// check<uint16_t>(" 42", 0);
|
||||
check<uint16_t>("x42", 0);
|
||||
check<uint16_t>("-1", 65535);
|
||||
check<uint16_t>("65536", 0);
|
||||
check<uint16_t>("true", 1);
|
||||
check<uint16_t>("false", 0);
|
||||
}
|
||||
Reference in new issue
Block a user