Update to ArduinoJson 7.0.4
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# ArduinoJson - https://arduinojson.org
|
||||
# Copyright © 2014-2023, Benoit BLANCHON
|
||||
# Copyright © 2014-2024, Benoit BLANCHON
|
||||
# MIT License
|
||||
|
||||
add_executable(MsgPackSerializerTests
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("serialize MsgPack to various destination types") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
object["hello"] = "world";
|
||||
const char* expected_result = "\x81\xA5hello\xA5world";
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
TEST_CASE("measureMsgPack()") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
object["hello"] = "world";
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
template <typename T>
|
||||
void check(T value, const std::string& expected) {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
doc.to<JsonVariant>().set(value);
|
||||
char buffer[256] = "";
|
||||
size_t returnValue = serializeMsgPack(doc, buffer, sizeof(buffer));
|
||||
@@ -13,7 +13,7 @@ void check(T value, const std::string& expected) {
|
||||
}
|
||||
|
||||
TEST_CASE("serializeMsgPack(MemberProxy)") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "{\"hello\":42}");
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
std::string result;
|
||||
@@ -24,7 +24,7 @@ TEST_CASE("serializeMsgPack(MemberProxy)") {
|
||||
}
|
||||
|
||||
TEST_CASE("serializeMsgPack(ElementProxy)") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "[42]");
|
||||
JsonArray arr = doc.as<JsonArray>();
|
||||
std::string result;
|
||||
@@ -35,7 +35,7 @@ TEST_CASE("serializeMsgPack(ElementProxy)") {
|
||||
}
|
||||
|
||||
TEST_CASE("serializeMsgPack(JsonVariantSubscript)") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "[42]");
|
||||
JsonVariant var = doc.as<JsonVariant>();
|
||||
std::string result;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#define ARDUINOJSON_SLOT_ID_SIZE 4 // required to reach 65536 elements
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
@@ -26,7 +28,7 @@ static void check(const JsonArray array, const std::string& expected) {
|
||||
}
|
||||
|
||||
TEST_CASE("serialize MsgPack array") {
|
||||
DynamicJsonDocument doc(JSON_ARRAY_SIZE(65536));
|
||||
JsonDocument doc;
|
||||
JsonArray array = doc.to<JsonArray>();
|
||||
|
||||
SECTION("empty") {
|
||||
@@ -53,6 +55,7 @@ TEST_CASE("serialize MsgPack array") {
|
||||
const char* nil = 0;
|
||||
for (int i = 0; i < 65536; i++)
|
||||
array.add(nil);
|
||||
REQUIRE(array.size() == 65536);
|
||||
|
||||
check(array,
|
||||
std::string("\xDD\x00\x01\x00\x00", 5) + std::string(65536, '\xc0'));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -28,7 +28,7 @@ static void check(const JsonObject object, const char (&expected_data)[N]) {
|
||||
//}
|
||||
|
||||
TEST_CASE("serialize MsgPack object") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject object = doc.to<JsonObject>();
|
||||
|
||||
SECTION("empty") {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -8,7 +8,7 @@
|
||||
template <typename T>
|
||||
static void checkVariant(T value, const char* expected_data,
|
||||
size_t expected_len) {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonVariant variant = doc.to<JsonVariant>();
|
||||
variant.set(value);
|
||||
std::string expected(expected_data, expected_data + expected_len);
|
||||
|
||||
Reference in New Issue
Block a user