Update to ArduinoJson 7.0.4
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
# ArduinoJson - https://arduinojson.org
|
||||
# Copyright © 2014-2023, Benoit BLANCHON
|
||||
# Copyright © 2014-2024, Benoit BLANCHON
|
||||
# MIT License
|
||||
|
||||
add_executable(MiscTests
|
||||
arithmeticCompare.cpp
|
||||
conflicts.cpp
|
||||
FloatParts.cpp
|
||||
issue1967.cpp
|
||||
JsonString.cpp
|
||||
NoArduinoHeader.cpp
|
||||
printable.cpp
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Numbers/FloatParts.hpp>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#define ARDUINO 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <Arduino.h>
|
||||
@@ -170,19 +170,19 @@ TEST_CASE("IteratorReader") {
|
||||
|
||||
class StreamStub : public Stream {
|
||||
public:
|
||||
StreamStub(const char* s) : _stream(s) {}
|
||||
StreamStub(const char* s) : stream_(s) {}
|
||||
|
||||
int read() {
|
||||
return _stream.get();
|
||||
return stream_.get();
|
||||
}
|
||||
|
||||
size_t readBytes(char* buffer, size_t length) {
|
||||
_stream.read(buffer, static_cast<std::streamsize>(length));
|
||||
return static_cast<size_t>(_stream.gcount());
|
||||
stream_.read(buffer, static_cast<std::streamsize>(length));
|
||||
return static_cast<size_t>(stream_.gcount());
|
||||
}
|
||||
|
||||
private:
|
||||
std::istringstream _stream;
|
||||
std::istringstream stream_;
|
||||
};
|
||||
|
||||
TEST_CASE("Reader<Stream>") {
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#define ARDUINOJSON_ENABLE_PROGMEM 1
|
||||
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
|
||||
|
||||
#include "custom_string.hpp"
|
||||
#include "progmem_emulation.hpp"
|
||||
#include "weird_strcmp.hpp"
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <ArduinoJson/Strings/IsString.hpp>
|
||||
#include <ArduinoJson/Strings/StringAdapters.hpp>
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "custom_string.hpp"
|
||||
#include "weird_strcmp.hpp"
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
TEST_CASE("ZeroTerminatedRamString") {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
|
||||
#include <Arduino.h>
|
||||
|
||||
#define ARDUINOJSON_STRING_BUFFER_SIZE 5
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "custom_string.hpp"
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
@@ -136,9 +139,9 @@ TEST_CASE("Writer<custom_string>") {
|
||||
}
|
||||
|
||||
TEST_CASE("serializeJson(doc, String)") {
|
||||
StaticJsonDocument<1024> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
::String output;
|
||||
::String output = "erase me";
|
||||
|
||||
SECTION("sufficient capacity") {
|
||||
serializeJson(doc, output);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -193,9 +193,7 @@ TEST_CASE("Polyfills/type_traits") {
|
||||
CHECK(is_convertible<MemberProxy<JsonObject, const char*>,
|
||||
JsonVariantConst>::value == true);
|
||||
CHECK(is_convertible<JsonObjectConst, JsonVariantConst>::value == true);
|
||||
CHECK(is_convertible<DynamicJsonDocument, JsonVariantConst>::value == true);
|
||||
CHECK(is_convertible<StaticJsonDocument<10>, JsonVariantConst>::value ==
|
||||
true);
|
||||
CHECK(is_convertible<JsonDocument, JsonVariantConst>::value == true);
|
||||
}
|
||||
|
||||
SECTION("is_class") {
|
||||
@@ -214,3 +212,8 @@ TEST_CASE("Polyfills/type_traits") {
|
||||
CHECK(is_enum<double>::value == false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("is_std_string") {
|
||||
REQUIRE(is_std_string<std::string>::value == true);
|
||||
REQUIRE(is_std_string<EmptyClass>::value == false);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Json/Utf16.hpp>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -10,9 +10,8 @@
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
static void testCodepoint(uint32_t codepoint, std::string expected) {
|
||||
char buffer[4096];
|
||||
MemoryPool pool(buffer, 4096);
|
||||
StringCopier str(&pool);
|
||||
ResourceManager resources;
|
||||
StringBuilder str(&resources);
|
||||
str.startString();
|
||||
|
||||
CAPTURE(codepoint);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Numbers/arithmeticCompare.hpp>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
// Include any header that might use the conflicting macros
|
||||
@@ -52,5 +52,11 @@
|
||||
#define BLOCKSIZE
|
||||
#define CAPACITY
|
||||
|
||||
// issue #1905
|
||||
#define _current
|
||||
|
||||
// issue #1914
|
||||
#define V7 7
|
||||
|
||||
// catch.hpp mutes several warnings, this file also allows to detect them
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
13
lib/ArduinoJson/extras/tests/Misc/issue1967.cpp
Normal file
13
lib/ArduinoJson/extras/tests/Misc/issue1967.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
// we expect ArduinoJson.h to include <string>
|
||||
#define ARDUINOJSON_ENABLE_STD_STRING 1
|
||||
|
||||
// but we don't want it to included accidentally
|
||||
#undef ARDUINO
|
||||
#define ARDUINOJSON_ENABLE_STD_STREAM 0
|
||||
#define ARDUINOJSON_ENABLE_STRING_VIEW 0
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <Arduino.h>
|
||||
@@ -8,6 +8,10 @@
|
||||
#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include "Allocators.hpp"
|
||||
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
|
||||
struct PrintOneCharacterAtATime {
|
||||
static size_t printStringTo(const std::string& s, Print& p) {
|
||||
size_t result = 0;
|
||||
@@ -29,27 +33,28 @@ struct PrintAllAtOnce {
|
||||
|
||||
template <typename PrintPolicy>
|
||||
struct PrintableString : public Printable {
|
||||
PrintableString(const char* s) : _str(s), _total(0) {}
|
||||
PrintableString(const char* s) : str_(s), total_(0) {}
|
||||
|
||||
virtual size_t printTo(Print& p) const {
|
||||
size_t result = PrintPolicy::printStringTo(_str, p);
|
||||
_total += result;
|
||||
size_t result = PrintPolicy::printStringTo(str_, p);
|
||||
total_ += result;
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t totalBytesWritten() const {
|
||||
return _total;
|
||||
return total_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _str;
|
||||
mutable size_t _total;
|
||||
std::string str_;
|
||||
mutable size_t total_;
|
||||
};
|
||||
|
||||
TEST_CASE("Printable") {
|
||||
SECTION("Doesn't overflow") {
|
||||
StaticJsonDocument<8> doc;
|
||||
const char* value = "example"; // == 7 chars
|
||||
SpyingAllocator spy;
|
||||
JsonDocument doc(&spy);
|
||||
const char* value = "example";
|
||||
|
||||
doc.set(666); // to make sure we override the value
|
||||
|
||||
@@ -59,8 +64,11 @@ TEST_CASE("Printable") {
|
||||
CHECK(doc.as<std::string>() == value);
|
||||
CHECK(printable.totalBytesWritten() == 7);
|
||||
CHECK(doc.overflowed() == false);
|
||||
CHECK(doc.memoryUsage() == 8);
|
||||
CHECK(doc.as<JsonVariant>().memoryUsage() == 8);
|
||||
CHECK(spy.log() ==
|
||||
AllocatorLog{
|
||||
Allocate(sizeofStringBuffer()),
|
||||
Reallocate(sizeofStringBuffer(), sizeofString("example")),
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("Via Print::write(const char* size_t)") {
|
||||
@@ -69,58 +77,90 @@ TEST_CASE("Printable") {
|
||||
CHECK(doc.as<std::string>() == value);
|
||||
CHECK(printable.totalBytesWritten() == 7);
|
||||
CHECK(doc.overflowed() == false);
|
||||
CHECK(doc.memoryUsage() == 8);
|
||||
CHECK(doc.as<JsonVariant>().memoryUsage() == 8);
|
||||
CHECK(spy.log() ==
|
||||
AllocatorLog{
|
||||
Allocate(sizeofStringBuffer()),
|
||||
Reallocate(sizeofStringBuffer(), sizeofString("example")),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Overflows early") {
|
||||
StaticJsonDocument<8> doc;
|
||||
const char* value = "hello world"; // > 8 chars
|
||||
SECTION("First allocation fails") {
|
||||
SpyingAllocator spy(FailingAllocator::instance());
|
||||
JsonDocument doc(&spy);
|
||||
const char* value = "hello world";
|
||||
|
||||
doc.set(666); // to make sure we override the value
|
||||
|
||||
SECTION("Via Print::write(char)") {
|
||||
PrintableString<PrintOneCharacterAtATime> printable(value);
|
||||
CHECK(doc.set(printable) == false);
|
||||
|
||||
bool success = doc.set(printable);
|
||||
|
||||
CHECK(success == false);
|
||||
CHECK(doc.isNull());
|
||||
CHECK(printable.totalBytesWritten() == 8);
|
||||
CHECK(printable.totalBytesWritten() == 0);
|
||||
CHECK(doc.overflowed() == true);
|
||||
CHECK(doc.memoryUsage() == 0);
|
||||
CHECK(spy.log() == AllocatorLog{
|
||||
AllocateFail(sizeofStringBuffer()),
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("Via Print::write(const char*, size_t)") {
|
||||
PrintableString<PrintAllAtOnce> printable(value);
|
||||
CHECK(doc.set(printable) == false);
|
||||
|
||||
bool success = doc.set(printable);
|
||||
|
||||
CHECK(success == false);
|
||||
CHECK(doc.isNull());
|
||||
CHECK(printable.totalBytesWritten() == 0);
|
||||
CHECK(doc.overflowed() == true);
|
||||
CHECK(doc.memoryUsage() == 0);
|
||||
CHECK(spy.log() == AllocatorLog{
|
||||
AllocateFail(sizeofStringBuffer()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Overflows adding terminator") {
|
||||
StaticJsonDocument<8> doc;
|
||||
const char* value = "overflow"; // == 8 chars
|
||||
SECTION("Reallocation fails") {
|
||||
TimebombAllocator timebomb(1);
|
||||
SpyingAllocator spy(&timebomb);
|
||||
JsonDocument doc(&spy);
|
||||
const char* value = "Lorem ipsum dolor sit amet, cons"; // > 31 chars
|
||||
|
||||
doc.set(666); // to make sure we override the value
|
||||
|
||||
SECTION("Via Print::write(char)") {
|
||||
PrintableString<PrintOneCharacterAtATime> printable(value);
|
||||
CHECK(doc.set(printable) == false);
|
||||
|
||||
bool success = doc.set(printable);
|
||||
|
||||
CHECK(success == false);
|
||||
CHECK(doc.isNull());
|
||||
CHECK(printable.totalBytesWritten() == 8);
|
||||
CHECK(printable.totalBytesWritten() == 31);
|
||||
CHECK(doc.overflowed() == true);
|
||||
CHECK(doc.memoryUsage() == 0);
|
||||
CHECK(spy.log() ==
|
||||
AllocatorLog{
|
||||
Allocate(sizeofStringBuffer()),
|
||||
ReallocateFail(sizeofStringBuffer(), sizeofStringBuffer(2)),
|
||||
Deallocate(sizeofStringBuffer()),
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("Via Print::write(const char*, size_t)") {
|
||||
PrintableString<PrintAllAtOnce> printable(value);
|
||||
CHECK(doc.set(printable) == false);
|
||||
|
||||
bool success = doc.set(printable);
|
||||
|
||||
CHECK(success == false);
|
||||
CHECK(doc.isNull());
|
||||
CHECK(printable.totalBytesWritten() == 0);
|
||||
CHECK(printable.totalBytesWritten() == 31);
|
||||
CHECK(doc.overflowed() == true);
|
||||
CHECK(doc.memoryUsage() == 0);
|
||||
CHECK(spy.log() ==
|
||||
AllocatorLog{
|
||||
Allocate(sizeofStringBuffer()),
|
||||
ReallocateFail(sizeofStringBuffer(), sizeofStringBuffer(2)),
|
||||
Deallocate(sizeofStringBuffer()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +173,20 @@ TEST_CASE("Printable") {
|
||||
}
|
||||
|
||||
SECTION("String deduplication") {
|
||||
StaticJsonDocument<128> doc;
|
||||
SpyingAllocator spy;
|
||||
JsonDocument doc(&spy);
|
||||
doc.add(PrintableString<PrintOneCharacterAtATime>("Hello World!"));
|
||||
doc.add(PrintableString<PrintAllAtOnce>("Hello World!"));
|
||||
REQUIRE(doc.size() == 2);
|
||||
CHECK(doc[0] == "Hello World!");
|
||||
CHECK(doc[1] == "Hello World!");
|
||||
CHECK(doc.memoryUsage() == JSON_ARRAY_SIZE(2) + 13);
|
||||
CHECK(spy.log() ==
|
||||
AllocatorLog{
|
||||
Allocate(sizeofPool()),
|
||||
Allocate(sizeofStringBuffer()),
|
||||
Reallocate(sizeofStringBuffer(), sizeofString("Hello World!")),
|
||||
Allocate(sizeofStringBuffer()),
|
||||
Deallocate(sizeofStringBuffer()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
@@ -13,7 +13,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("deserializeJson()") {
|
||||
unsigned char input[] = "{\"a\":42}";
|
||||
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(1)> doc;
|
||||
JsonDocument doc;
|
||||
DeserializationError err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
@@ -22,7 +22,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("deserializeMsgPack()") {
|
||||
unsigned char input[] = "\xDE\x00\x01\xA5Hello\xA5world";
|
||||
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
DeserializationError err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
@@ -30,7 +30,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeMsgPack(unsigned char[])") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeMsgPack(doc, buffer);
|
||||
@@ -41,7 +41,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeMsgPack(unsigned char*)") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeMsgPack(doc, buffer, sizeof(buffer));
|
||||
@@ -52,7 +52,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeJson(unsigned char[])") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeJson(doc, buffer);
|
||||
@@ -63,7 +63,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeJson(unsigned char*)") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeJson(doc, buffer, sizeof(buffer));
|
||||
@@ -74,7 +74,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeJsonPretty(unsigned char[])") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeJsonPretty(doc, buffer);
|
||||
@@ -84,7 +84,7 @@ TEST_CASE("unsigned char[]") {
|
||||
|
||||
SECTION("serializeJsonPretty(unsigned char*)") {
|
||||
unsigned char buffer[32];
|
||||
StaticJsonDocument<JSON_OBJECT_SIZE(2)> doc;
|
||||
JsonDocument doc;
|
||||
doc["hello"] = "world";
|
||||
|
||||
size_t n = serializeJsonPretty(doc, buffer, sizeof(buffer));
|
||||
@@ -93,7 +93,7 @@ TEST_CASE("unsigned char[]") {
|
||||
}
|
||||
|
||||
SECTION("JsonVariant") {
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set") {
|
||||
unsigned char value[] = "42";
|
||||
@@ -156,7 +156,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("operator[]") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj[key] = "world";
|
||||
|
||||
@@ -166,7 +166,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("JsonObject::operator[] const") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
@@ -177,7 +177,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("containsKey()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
REQUIRE(true == obj.containsKey(key));
|
||||
@@ -186,36 +186,20 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("remove()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
deserializeJson(doc, "{\"hello\":\"world\"}");
|
||||
JsonObject obj = doc.as<JsonObject>();
|
||||
obj.remove(key);
|
||||
|
||||
REQUIRE(0 == obj.size());
|
||||
}
|
||||
|
||||
SECTION("createNestedArray()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj.createNestedArray(key);
|
||||
}
|
||||
|
||||
SECTION("createNestedObject()") {
|
||||
unsigned char key[] = "hello";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj.createNestedObject(key);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("MemberProxy") {
|
||||
SECTION("operator=") { // issue #416
|
||||
unsigned char value[] = "world";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["hello"] = value;
|
||||
|
||||
@@ -225,7 +209,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("set()") {
|
||||
unsigned char value[] = "world";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonObject obj = doc.to<JsonObject>();
|
||||
obj["hello"].set(value);
|
||||
|
||||
@@ -237,7 +221,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("add()") {
|
||||
unsigned char value[] = "world";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonArray arr = doc.to<JsonArray>();
|
||||
arr.add(value);
|
||||
|
||||
@@ -249,7 +233,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("set()") {
|
||||
unsigned char value[] = "world";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonArray arr = doc.to<JsonArray>();
|
||||
arr.add("hello");
|
||||
arr[0].set(value);
|
||||
@@ -260,7 +244,7 @@ TEST_CASE("unsigned char[]") {
|
||||
SECTION("operator=") {
|
||||
unsigned char value[] = "world";
|
||||
|
||||
DynamicJsonDocument doc(4096);
|
||||
JsonDocument doc;
|
||||
JsonArray arr = doc.to<JsonArray>();
|
||||
arr.add("hello");
|
||||
arr[0] = value;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/version.hpp>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// Copyright © 2014-2024, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
Reference in New Issue
Block a user