string_length_size_4.cpp 837 B

1234567891011121314151617181920212223242526272829303132
  1. #define ARDUINOJSON_STRING_LENGTH_SIZE 4
  2. #include <ArduinoJson.h>
  3. #include <catch.hpp>
  4. #include <string>
  5. TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 4") {
  6. JsonDocument doc;
  7. SECTION("set() returns true if string has 65536 characters") {
  8. auto result = doc.set(std::string(65536, '?'));
  9. REQUIRE(result == true);
  10. REQUIRE(doc.overflowed() == false);
  11. }
  12. SECTION("deserializeJson() returns Ok if string has 65536 characters") {
  13. auto input = "\"" + std::string(65536, '?') + "\"";
  14. auto err = deserializeJson(doc, input);
  15. REQUIRE(err == DeserializationError::Ok);
  16. }
  17. SECTION("deserializeMsgPack() returns Ok of string has 65536 characters") {
  18. auto input = "\xda\xff\xff" + std::string(65536, '?');
  19. auto err = deserializeMsgPack(doc, input);
  20. REQUIRE(err == DeserializationError::Ok);
  21. }
  22. }