parseNumber.cpp 698 B

123456789101112131415161718192021222324
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #include <ArduinoJson/Numbers/parseNumber.hpp>
  5. #include <catch.hpp>
  6. using namespace ARDUINOJSON_NAMESPACE;
  7. TEST_CASE("Test uint32_t overflow") {
  8. ParsedNumber<float, uint32_t> first =
  9. parseNumber<float, uint32_t>("4294967295");
  10. ParsedNumber<float, uint32_t> second =
  11. parseNumber<float, uint32_t>("4294967296");
  12. REQUIRE(first.type() == uint8_t(VALUE_IS_POSITIVE_INTEGER));
  13. REQUIRE(second.type() == uint8_t(VALUE_IS_FLOAT));
  14. }
  15. TEST_CASE("Invalid value") {
  16. ParsedNumber<float, uint32_t> result = parseNumber<float, uint32_t>("6a3");
  17. REQUIRE(result.type() == uint8_t(VALUE_IS_NULL));
  18. }