2018-07-04 11:57:30 +02:00
|
|
|
// ArduinoJson - arduinojson.org
|
2019-02-15 13:31:46 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2019
|
2018-07-04 11:57:30 +02:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson/Numbers/isInteger.hpp>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
2018-10-02 16:54:05 +02:00
|
|
|
using namespace ARDUINOJSON_NAMESPACE;
|
2018-07-04 11:57:30 +02:00
|
|
|
|
|
|
|
TEST_CASE("isInteger()") {
|
|
|
|
SECTION("Null") {
|
|
|
|
REQUIRE(isInteger(NULL) == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Empty string") {
|
|
|
|
REQUIRE(isInteger("") == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("FloatNotInteger") {
|
|
|
|
REQUIRE(isInteger("3.14") == false);
|
|
|
|
REQUIRE(isInteger("-3.14") == false);
|
|
|
|
REQUIRE(isInteger("+3.14") == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Spaces") {
|
|
|
|
REQUIRE(isInteger("42 ") == false);
|
|
|
|
REQUIRE(isInteger(" 42") == false);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("Valid") {
|
|
|
|
REQUIRE(isInteger("42") == true);
|
|
|
|
REQUIRE(isInteger("-42") == true);
|
|
|
|
REQUIRE(isInteger("+42") == true);
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("ExtraSign") {
|
|
|
|
REQUIRE(isInteger("--42") == false);
|
|
|
|
REQUIRE(isInteger("++42") == false);
|
|
|
|
}
|
|
|
|
}
|