issue1120.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #include <ArduinoJson.h>
  2. #include <catch.hpp>
  3. #include "Literals.hpp"
  4. TEST_CASE("Issue #1120") {
  5. JsonDocument doc;
  6. constexpr char str[] =
  7. "{\"contents\":[{\"module\":\"Packet\"},{\"module\":\"Analog\"}]}";
  8. deserializeJson(doc, str);
  9. SECTION("MemberProxy<std::string>::isNull()") {
  10. SECTION("returns false") {
  11. CHECK(doc["contents"_s].isNull() == false);
  12. }
  13. SECTION("returns true") {
  14. CHECK(doc["zontents"_s].isNull() == true);
  15. }
  16. }
  17. SECTION("ElementProxy<MemberProxy<const char*> >::isNull()") {
  18. SECTION("returns false") { // Issue #1120
  19. CHECK(doc["contents"][1].isNull() == false);
  20. }
  21. SECTION("returns true") {
  22. CHECK(doc["contents"][2].isNull() == true);
  23. }
  24. }
  25. SECTION("MemberProxy<ElementProxy<MemberProxy>, const char*>::isNull()") {
  26. SECTION("returns false") {
  27. CHECK(doc["contents"][1]["module"].isNull() == false);
  28. }
  29. SECTION("returns true") {
  30. CHECK(doc["contents"][1]["zodule"].isNull() == true);
  31. }
  32. }
  33. SECTION("MemberProxy<ElementProxy<MemberProxy>, std::string>::isNull()") {
  34. SECTION("returns false") {
  35. CHECK(doc["contents"][1]["module"_s].isNull() == false);
  36. }
  37. SECTION("returns true") {
  38. CHECK(doc["contents"][1]["zodule"_s].isNull() == true);
  39. }
  40. }
  41. }