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:
@@ -15,6 +15,9 @@ add_executable(MixedConfigurationTests
|
||||
enable_nan_1.cpp
|
||||
enable_progmem_1.cpp
|
||||
issue1707.cpp
|
||||
string_length_size_1.cpp
|
||||
string_length_size_2.cpp
|
||||
string_length_size_4.cpp
|
||||
use_double_0.cpp
|
||||
use_double_1.cpp
|
||||
use_long_long_0.cpp
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#define ARDUINOJSON_STRING_LENGTH_SIZE 1
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 1") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if len <= 255") {
|
||||
auto result = doc.set(std::string(255, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if len >= 256") {
|
||||
auto result = doc.set(std::string(256, '?'));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size <= 253") {
|
||||
auto str = std::string(253, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 254") {
|
||||
auto str = std::string(254, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackExtension)") {
|
||||
SECTION("returns true if size <= 252") {
|
||||
auto str = std::string(252, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 253") {
|
||||
auto str = std::string(253, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length <= 255") {
|
||||
auto input = "\"" + std::string(255, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 256") {
|
||||
auto input = "\"" + std::string(256, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string length <= 255") {
|
||||
auto input = "\xd9\xff" + std::string(255, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 256") {
|
||||
auto input = "\xda\x01\x00"_s + std::string(256, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if binary size <= 253") {
|
||||
auto input = "\xc4\xfd" + std::string(253, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if binary size >= 254") {
|
||||
auto input = "\xc4\xfe" + std::string(254, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if extension size <= 252") {
|
||||
auto input = "\xc7\xfc\x01" + std::string(252, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if binary size >= 253") {
|
||||
auto input = "\xc7\xfd\x01" + std::string(253, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
#define ARDUINOJSON_STRING_LENGTH_SIZE 2
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 2") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if len <= 65535") {
|
||||
auto result = doc.set(std::string(65535, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if len >= 65536") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size <= 65532") {
|
||||
auto str = std::string(65532, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 65533") {
|
||||
auto str = std::string(65533, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackExtension)") {
|
||||
SECTION("returns true if size <= 65531") {
|
||||
auto str = std::string(65531, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns false if size >= 65532") {
|
||||
auto str = std::string(65532, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == false);
|
||||
REQUIRE(doc.overflowed() == true);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length <= 65535") {
|
||||
auto input = "\"" + std::string(65535, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 65536") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string length <= 65535") {
|
||||
auto input = "\xda\xff\xff" + std::string(65535, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if string length >= 65536") {
|
||||
auto input = "\xdb\x00\x01\x00\x00"_s + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if binary size <= 65532") {
|
||||
auto input = "\xc5\xff\xfc" + std::string(65532, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if binary size >= 65534") {
|
||||
auto input = "\xc5\xff\xfd" + std::string(65534, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
// https://oss-fuzz.com/testcase?key=5354792971993088
|
||||
SECTION("doesn't overflow if binary size == 0xFFFF") {
|
||||
auto input = "\xc5\xff\xff"_s;
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if extension size <= 65531") {
|
||||
auto input = "\xc8\xff\xfb\x01" + std::string(65531, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns NoMemory if extension size >= 65532") {
|
||||
auto input = "\xc8\xff\xfc\x01" + std::string(65532, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
#define ARDUINOJSON_STRING_LENGTH_SIZE 4
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include <catch.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("ARDUINOJSON_STRING_LENGTH_SIZE == 4") {
|
||||
JsonDocument doc;
|
||||
|
||||
SECTION("set(std::string)") {
|
||||
SECTION("returns true if string length >= 65536") {
|
||||
auto result = doc.set(std::string(65536, '?'));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackBinary)") {
|
||||
SECTION("returns true if size >= 65536") {
|
||||
auto str = std::string(65536, '?');
|
||||
auto result = doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("set(MsgPackExtension)") {
|
||||
SECTION("returns true if size >= 65532") {
|
||||
auto str = std::string(65532, '?');
|
||||
auto result = doc.set(MsgPackExtension(1, str.data(), str.size()));
|
||||
|
||||
REQUIRE(result == true);
|
||||
REQUIRE(doc.overflowed() == false);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeJson()") {
|
||||
SECTION("returns Ok if string length >= 65536") {
|
||||
auto input = "\"" + std::string(65536, '?') + "\"";
|
||||
|
||||
auto err = deserializeJson(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("returns Ok if string size >= 65536") {
|
||||
auto input = "\xda\xff\xff" + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if binary size >= 65536") {
|
||||
auto input = "\xc5\xff\xff" + std::string(65536, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
SECTION("returns Ok if extension size >= 65532") {
|
||||
auto input = "\xc8\xff\xfb\x01" + std::string(65532, '?');
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
}
|
||||
|
||||
// https://oss-fuzz.com/testcase?key=5354792971993088
|
||||
SECTION("doesn't overflow if binary size == 0xFFFFFFFF") {
|
||||
auto input = "\xc6\xff\xff\xff\xff"_s;
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::NoMemory);
|
||||
}
|
||||
|
||||
SECTION("doesn't overflow if string size == 0xFFFFFFFF") {
|
||||
auto input = "\xdb\xff\xff\xff\xff???????????????????"_s;
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err != DeserializationError::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("bin 32 deserialization") {
|
||||
auto str = std::string(65536, '?');
|
||||
auto input = "\xc6\x00\x01\x00\x00"_s + str;
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<MsgPackBinary>());
|
||||
auto binary = doc.as<MsgPackBinary>();
|
||||
REQUIRE(binary.size() == 65536);
|
||||
REQUIRE(binary.data() != nullptr);
|
||||
REQUIRE(std::string(reinterpret_cast<const char*>(binary.data()),
|
||||
binary.size()) == str);
|
||||
}
|
||||
|
||||
SECTION("bin 32 serialization") {
|
||||
auto str = std::string(65536, '?');
|
||||
doc.set(MsgPackBinary(str.data(), str.size()));
|
||||
|
||||
std::string output;
|
||||
auto result = serializeMsgPack(doc, output);
|
||||
|
||||
REQUIRE(result == 5 + str.size());
|
||||
REQUIRE(output == "\xc6\x00\x01\x00\x00"_s + str);
|
||||
}
|
||||
|
||||
SECTION("ext 32 deserialization") {
|
||||
auto str = std::string(65536, '?');
|
||||
auto input = "\xc9\x00\x01\x00\x00\x2a"_s + str;
|
||||
|
||||
auto err = deserializeMsgPack(doc, input);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(doc.is<MsgPackExtension>());
|
||||
auto value = doc.as<MsgPackExtension>();
|
||||
REQUIRE(value.type() == 42);
|
||||
REQUIRE(value.size() == 65536);
|
||||
REQUIRE(value.data() != nullptr);
|
||||
REQUIRE(std::string(reinterpret_cast<const char*>(value.data()),
|
||||
value.size()) == str);
|
||||
}
|
||||
|
||||
SECTION("ext 32 serialization") {
|
||||
auto str = std::string(65536, '?');
|
||||
doc.set(MsgPackExtension(42, str.data(), str.size()));
|
||||
|
||||
std::string output;
|
||||
auto result = serializeMsgPack(doc, output);
|
||||
|
||||
REQUIRE(result == 6 + str.size());
|
||||
REQUIRE(output == "\xc9\x00\x01\x00\x00\x2a"_s + str);
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,40 @@
|
||||
|
||||
#include <catch.hpp>
|
||||
|
||||
#include "Literals.hpp"
|
||||
|
||||
TEST_CASE("ARDUINOJSON_USE_LONG_LONG == 0") {
|
||||
JsonDocument doc;
|
||||
|
||||
doc["A"] = 42;
|
||||
doc["B"] = 84;
|
||||
SECTION("smoke test") {
|
||||
doc["A"] = 42;
|
||||
doc["B"] = 84;
|
||||
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
|
||||
REQUIRE(json == "{\"A\":42,\"B\":84}");
|
||||
REQUIRE(json == "{\"A\":42,\"B\":84}");
|
||||
}
|
||||
|
||||
SECTION("deserializeMsgPack()") {
|
||||
SECTION("cf 00 00 00 00 ff ff ff ff") {
|
||||
auto err =
|
||||
deserializeMsgPack(doc, "\xcf\x00\x00\x00\x00\xff\xff\xff\xff"_s);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
REQUIRE(doc.as<uint32_t>() == 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
SECTION("cf 00 00 00 01 00 00 00 00") {
|
||||
auto err =
|
||||
deserializeMsgPack(doc, "\xcf\x00\x00\x00\x01\x00\x00\x00\x00"_s);
|
||||
|
||||
REQUIRE(err == DeserializationError::Ok);
|
||||
#if defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ >= 8
|
||||
REQUIRE(doc.as<JsonInteger>() == 0x100000000);
|
||||
#else
|
||||
REQUIRE(doc.isNull());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user