incomplete_input.cpp 856 B

123456789101112131415161718192021222324252627
  1. // ArduinoJson - arduinojson.org
  2. // Copyright Benoit Blanchon 2014-2019
  3. // MIT License
  4. #define ARDUINOJSON_DECODE_UNICODE 1
  5. #include <ArduinoJson.h>
  6. #include <catch.hpp>
  7. TEST_CASE("Truncated JSON input") {
  8. const char* testCases[] = {"\"hello", "\'hello", "'\\u", "'\\u00", "'\\u000",
  9. // false
  10. "f", "fa", "fal", "fals",
  11. // true
  12. "t", "tr", "tru",
  13. // null
  14. "n", "nu", "nul"};
  15. const size_t testCount = sizeof(testCases) / sizeof(testCases[0]);
  16. DynamicJsonDocument doc(4096);
  17. for (size_t i = 0; i < testCount; i++) {
  18. const char* input = testCases[i];
  19. CAPTURE(input);
  20. REQUIRE(deserializeJson(doc, input) ==
  21. DeserializationError::IncompleteInput);
  22. }
  23. }