You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
893 B
44 lines
893 B
3 years ago
|
#include <ArduinoJson.h>
|
||
|
|
||
|
#include <catch.hpp>
|
||
|
|
||
|
TEST_CASE("nullptr") {
|
||
|
DynamicJsonDocument doc(4096);
|
||
|
JsonVariant variant = doc.to<JsonVariant>();
|
||
|
|
||
|
SECTION("JsonVariant == nullptr") {
|
||
2 years ago
|
REQUIRE(variant == nullptr);
|
||
|
REQUIRE_FALSE(variant != nullptr);
|
||
3 years ago
|
}
|
||
|
|
||
|
SECTION("JsonVariant != nullptr") {
|
||
|
variant.set(42);
|
||
|
|
||
2 years ago
|
REQUIRE_FALSE(variant == nullptr);
|
||
|
REQUIRE(variant != nullptr);
|
||
3 years ago
|
}
|
||
|
|
||
|
SECTION("JsonVariant.set(nullptr)") {
|
||
|
variant.set(42);
|
||
|
variant.set(nullptr);
|
||
|
|
||
|
REQUIRE(variant.isNull());
|
||
|
}
|
||
|
|
||
3 years ago
|
SECTION("JsonVariant.set(nullptr) with unbound reference") {
|
||
|
JsonVariant unboundReference;
|
||
|
|
||
|
unboundReference.set(nullptr);
|
||
|
|
||
|
REQUIRE(variant.isNull());
|
||
|
}
|
||
|
|
||
3 years ago
|
SECTION("JsonVariant.is<nullptr_t>()") {
|
||
|
variant.set(42);
|
||
|
REQUIRE(variant.is<std::nullptr_t>() == false);
|
||
|
|
||
|
variant.clear();
|
||
|
REQUIRE(variant.is<std::nullptr_t>() == true);
|
||
|
}
|
||
|
}
|