2017-11-07 20:42:50 +01:00
|
|
|
// ArduinoJson - arduinojson.org
|
2017-03-25 21:55:13 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2017
|
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson/Polyfills/isInteger.hpp>
|
2017-04-18 18:22:24 +02:00
|
|
|
#include <catch.hpp>
|
2017-03-25 21:55:13 +01:00
|
|
|
|
|
|
|
using namespace ArduinoJson::Polyfills;
|
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
TEST_CASE("isInteger()") {
|
|
|
|
SECTION("Null") {
|
|
|
|
REQUIRE_FALSE(isInteger(NULL));
|
2017-03-25 21:55:13 +01:00
|
|
|
}
|
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("FloatNotInteger") {
|
|
|
|
REQUIRE_FALSE(isInteger("3.14"));
|
|
|
|
REQUIRE_FALSE(isInteger("-3.14"));
|
|
|
|
REQUIRE_FALSE(isInteger("+3.14"));
|
|
|
|
}
|
2017-03-25 21:55:13 +01:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("Spaces") {
|
|
|
|
REQUIRE_FALSE(isInteger("42 "));
|
|
|
|
REQUIRE_FALSE(isInteger(" 42"));
|
|
|
|
}
|
2017-03-25 21:55:13 +01:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("Valid") {
|
|
|
|
REQUIRE(isInteger("42"));
|
|
|
|
REQUIRE(isInteger("-42"));
|
|
|
|
REQUIRE(isInteger("+42"));
|
|
|
|
}
|
2017-03-25 21:55:13 +01:00
|
|
|
|
2017-04-18 18:22:24 +02:00
|
|
|
SECTION("ExtraSign") {
|
|
|
|
REQUIRE_FALSE(isInteger("--42"));
|
|
|
|
REQUIRE_FALSE(isInteger("++42"));
|
|
|
|
}
|
2017-03-25 21:55:13 +01:00
|
|
|
}
|