2019-05-26 11:31:51 +02:00
|
|
|
#include <ArduinoJson.h>
|
|
|
|
|
|
|
|
#include <catch.hpp>
|
|
|
|
|
2024-06-07 09:35:45 +02:00
|
|
|
#include "Literals.hpp"
|
|
|
|
|
2019-10-30 19:09:21 +01:00
|
|
|
TEST_CASE("Issue #1120") {
|
2023-07-17 18:15:13 +02:00
|
|
|
JsonDocument doc;
|
2019-10-30 19:09:21 +01:00
|
|
|
constexpr char str[] =
|
|
|
|
"{\"contents\":[{\"module\":\"Packet\"},{\"module\":\"Analog\"}]}";
|
|
|
|
deserializeJson(doc, str);
|
|
|
|
|
|
|
|
SECTION("MemberProxy<std::string>::isNull()") {
|
|
|
|
SECTION("returns false") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"_s].isNull() == false);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["zontents"_s].isNull() == true);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("ElementProxy<MemberProxy<const char*> >::isNull()") {
|
|
|
|
SECTION("returns false") { // Issue #1120
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][1].isNull() == false);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][2].isNull() == true);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("MemberProxy<ElementProxy<MemberProxy>, const char*>::isNull()") {
|
|
|
|
SECTION("returns false") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][1]["module"].isNull() == false);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][1]["zodule"].isNull() == true);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("MemberProxy<ElementProxy<MemberProxy>, std::string>::isNull()") {
|
|
|
|
SECTION("returns false") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][1]["module"_s].isNull() == false);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SECTION("returns true") {
|
2024-11-25 10:46:21 +01:00
|
|
|
CHECK(doc["contents"][1]["zodule"_s].isNull() == true);
|
2019-10-30 19:09:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|