// ArduinoJson - arduinojson.org // Copyright Benoit Blanchon 2014-2019 // MIT License #include #include #include using namespace ARDUINOJSON_NAMESPACE; template void check(const char* input, T expected) { CAPTURE(input); T actual = parseInteger(input); REQUIRE(expected == actual); } TEST_CASE("parseInteger()") { check("-128", -128); check("127", 127); check("+127", 127); check("3.14", 3); check("x42", 0); check("128", 0); // overflow check("-129", 0); // overflow } TEST_CASE("parseInteger()") { check("-32768", -32768); check("32767", 32767); check("+32767", 32767); check("3.14", 3); check("x42", 0); check("-32769", 0); // overflow check("32768", 0); // overflow } TEST_CASE("parseInteger()") { check("-2147483648", (-2147483647 - 1)); check("2147483647", 2147483647); check("+2147483647", 2147483647); check("3.14", 3); check("x42", 0); check("-2147483649", 0); // overflow check("2147483648", 0); // overflow } TEST_CASE("parseInteger()") { check("0", 0); check("255", 255); check("+255", 255); check("3.14", 3); check("x42", 0); check("-1", 0); check("256", 0); } TEST_CASE("parseInteger()") { check("0", 0); check("65535", 65535); check("+65535", 65535); check("3.14", 3); // check(" 42", 0); check("x42", 0); check("-1", 0); check("65536", 0); }