Issue90.cpp 888 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright Benoit Blanchon 2014-2017
  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) {
  18. ASSERT_FALSE(variant.is<long>());
  19. }
  20. TEST(SUITE, AsLong) {
  21. ASSERT_EQ(LONG_MAX, variant.as<long>());
  22. }
  23. TEST(SUITE, IsAString) {
  24. ASSERT_FALSE(variant.is<const char*>());
  25. }
  26. TEST(SUITE, AsString) {
  27. ASSERT_STREQ(superLong, variant.as<const char*>());
  28. }