Issue90.cpp 922 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright Benoit Blanchon 2014-2016
  2. // MIT License
  3. //
  4. // Arduino JSON library
  5. // https://github.com/bblanchon/ArduinoJson
  6. // If you like this project, please add a star!
  7. #include <gtest/gtest.h>
  8. #include <limits.h> // for LONG_MAX
  9. #define ARDUINOJSON_USE_LONG_LONG 0
  10. #define ARDUINOJSON_USE_INT64 0
  11. #include <ArduinoJson.h>
  12. #define SUITE Issue90
  13. using namespace ArduinoJson::Internals;
  14. static const char* superLong =
  15. "12345678901234567890123456789012345678901234567890123456789012345678901234"
  16. "5678901234567890123456789012345678901234567890123456789012345678901234567";
  17. static const JsonVariant variant = Unparsed(superLong);
  18. TEST(SUITE, IsNotALong) { ASSERT_FALSE(variant.is<long>()); }
  19. TEST(SUITE, AsLong) { ASSERT_EQ(LONG_MAX, variant.as<long>()); }
  20. TEST(SUITE, IsAString) { ASSERT_FALSE(variant.is<const char*>()); }
  21. TEST(SUITE, AsString) { ASSERT_STREQ(superLong, variant.as<const char*>()); }