2019-03-06 15:31:37 +01:00
|
|
|
// ArduinoJson - arduinojson.org
|
2020-01-09 15:48:38 +01:00
|
|
|
// Copyright Benoit Blanchon 2014-2020
|
2019-03-06 15:31:37 +01:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
#include <ArduinoJson/Numbers/parseNumber.hpp>
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
|
|
|
using namespace ARDUINOJSON_NAMESPACE;
|
|
|
|
|
|
|
|
TEST_CASE("Test uint32_t overflow") {
|
2020-07-26 12:23:55 +02:00
|
|
|
ParsedNumber<float, uint32_t> first, second;
|
|
|
|
parseNumber("4294967295", first);
|
|
|
|
parseNumber("4294967296", second);
|
2019-03-06 15:31:37 +01:00
|
|
|
|
|
|
|
REQUIRE(first.type() == uint8_t(VALUE_IS_POSITIVE_INTEGER));
|
|
|
|
REQUIRE(second.type() == uint8_t(VALUE_IS_FLOAT));
|
|
|
|
}
|
2019-04-20 15:12:29 +02:00
|
|
|
|
|
|
|
TEST_CASE("Invalid value") {
|
2020-07-26 12:23:55 +02:00
|
|
|
ParsedNumber<float, uint32_t> result;
|
|
|
|
parseNumber("6a3", result);
|
2019-04-20 15:12:29 +02:00
|
|
|
|
|
|
|
REQUIRE(result.type() == uint8_t(VALUE_IS_NULL));
|
|
|
|
}
|