Update ArduinoJSON, esp-nimble-cpp, Arduino Core, ESP-IDF (#448)
* ArduinoJSON 7.1.0 * Update nimble and arduino core * Update nuki_ble
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include <stdint.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("JsonVariantConst::as<T>()") {
|
||||
JsonDocument doc;
|
||||
JsonVariantConst var = doc.to<JsonVariant>();
|
||||
@@ -14,6 +16,27 @@ TEST_CASE("JsonVariantConst::as<T>()") {
|
||||
|
||||
REQUIRE(var.as<bool>() == true);
|
||||
REQUIRE(var.as<long>() == 0L);
|
||||
REQUIRE(var.as<const char*>() == std::string("hello"));
|
||||
REQUIRE(var.as<std::string>() == std::string("hello"));
|
||||
REQUIRE(var.as<const char*>() == "hello"_s);
|
||||
REQUIRE(var.as<std::string>() == "hello"_s);
|
||||
}
|
||||
|
||||
TEST_CASE("Invalid conversions") {
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
JsonVariantConst variant;
|
||||
|
||||
CHECK(is_same<decltype(variant.as<int>()), int>::value);
|
||||
CHECK(is_same<decltype(variant.as<float>()), float>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonVariantConst>()),
|
||||
JsonVariantConst>::value);
|
||||
CHECK(
|
||||
is_same<decltype(variant.as<JsonObjectConst>()), JsonObjectConst>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonArrayConst>()), JsonArrayConst>::value);
|
||||
|
||||
CHECK(is_same<decltype(variant.as<JsonVariant>()),
|
||||
InvalidConversion<JsonVariantConst, JsonVariant>>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonObject>()),
|
||||
InvalidConversion<JsonVariantConst, JsonObject>>::value);
|
||||
CHECK(is_same<decltype(variant.as<JsonArray>()),
|
||||
InvalidConversion<JsonVariantConst, JsonArray>>::value);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <stdint.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("JsonVariantConst::containsKey()") {
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
@@ -17,8 +19,8 @@ TEST_CASE("JsonVariantConst::containsKey()") {
|
||||
}
|
||||
|
||||
SECTION("support std::string") {
|
||||
REQUIRE(var.containsKey(std::string("hello")) == true);
|
||||
REQUIRE(var.containsKey(std::string("world")) == false);
|
||||
REQUIRE(var.containsKey("hello"_s) == true);
|
||||
REQUIRE(var.containsKey("world"_s) == false);
|
||||
}
|
||||
|
||||
#ifdef HAS_VARIABLE_LENGTH_ARRAY
|
||||
@@ -30,4 +32,10 @@ TEST_CASE("JsonVariantConst::containsKey()") {
|
||||
REQUIRE(true == var.containsKey(vla));
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("support JsonVariant") {
|
||||
doc["key"] = "hello";
|
||||
REQUIRE(var.containsKey(var["key"]) == true);
|
||||
REQUIRE(var.containsKey(var["foo"]) == false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("JsonVariantConst::operator[]") {
|
||||
JsonDocument doc;
|
||||
JsonVariantConst var = doc.to<JsonVariant>();
|
||||
@@ -27,13 +29,23 @@ TEST_CASE("JsonVariantConst::operator[]") {
|
||||
array.add("A");
|
||||
array.add("B");
|
||||
|
||||
REQUIRE(std::string("A") == var[0]);
|
||||
REQUIRE(std::string("B") == var[1]);
|
||||
REQUIRE(std::string("A") ==
|
||||
var[static_cast<unsigned char>(0)]); // issue #381
|
||||
REQUIRE(var[666].isNull());
|
||||
REQUIRE(var[3].isNull());
|
||||
REQUIRE(var["0"].isNull());
|
||||
SECTION("int") {
|
||||
REQUIRE("A"_s == var[0]);
|
||||
REQUIRE("B"_s == var[1]);
|
||||
REQUIRE("A"_s == var[static_cast<unsigned char>(0)]); // issue #381
|
||||
REQUIRE(var[666].isNull());
|
||||
REQUIRE(var[3].isNull());
|
||||
}
|
||||
|
||||
SECTION("const char*") {
|
||||
REQUIRE(var["0"].isNull());
|
||||
}
|
||||
|
||||
SECTION("JsonVariant") {
|
||||
array.add(1);
|
||||
REQUIRE(var[var[2]] == "B"_s);
|
||||
REQUIRE(var[var[3]].isNull());
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("object") {
|
||||
@@ -42,16 +54,16 @@ TEST_CASE("JsonVariantConst::operator[]") {
|
||||
object["b"] = "B";
|
||||
|
||||
SECTION("supports const char*") {
|
||||
REQUIRE(std::string("A") == var["a"]);
|
||||
REQUIRE(std::string("B") == var["b"]);
|
||||
REQUIRE("A"_s == var["a"]);
|
||||
REQUIRE("B"_s == var["b"]);
|
||||
REQUIRE(var["c"].isNull());
|
||||
REQUIRE(var[0].isNull());
|
||||
}
|
||||
|
||||
SECTION("supports std::string") {
|
||||
REQUIRE(std::string("A") == var[std::string("a")]);
|
||||
REQUIRE(std::string("B") == var[std::string("b")]);
|
||||
REQUIRE(var[std::string("c")].isNull());
|
||||
REQUIRE("A"_s == var["a"_s]);
|
||||
REQUIRE("B"_s == var["b"_s]);
|
||||
REQUIRE(var["c"_s].isNull());
|
||||
}
|
||||
|
||||
#if defined(HAS_VARIABLE_LENGTH_ARRAY) && \
|
||||
@@ -61,8 +73,14 @@ TEST_CASE("JsonVariantConst::operator[]") {
|
||||
char vla[i];
|
||||
strcpy(vla, "a");
|
||||
|
||||
REQUIRE(std::string("A") == var[vla]);
|
||||
REQUIRE("A"_s == var[vla]);
|
||||
}
|
||||
#endif
|
||||
|
||||
SECTION("supports JsonVariant") {
|
||||
object["c"] = "b";
|
||||
REQUIRE(var[var["c"]] == "B");
|
||||
REQUIRE(var[var["d"]].isNull());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user