Issue90.cpp 880 B

1234567891011121314151617181920212223242526272829
  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. static const char* superLong =
  14. "12345678901234567890123456789012345678901234567890123456789012345678901234"
  15. "5678901234567890123456789012345678901234567890123456789012345678901234567";
  16. static const JsonVariant variant = RawJson(superLong);
  17. TEST(SUITE, IsNotALong) { ASSERT_FALSE(variant.is<long>()); }
  18. TEST(SUITE, AsLong) { ASSERT_EQ(LONG_MAX, variant.as<long>()); }
  19. TEST(SUITE, IsAString) { ASSERT_FALSE(variant.is<const char*>()); }
  20. TEST(SUITE, AsString) { ASSERT_STREQ(superLong, variant.as<const char*>()); }