update ArduinoJson

This commit is contained in:
technyon
2023-03-11 11:11:14 +01:00
parent d134dc9aab
commit 7576244142
368 changed files with 17459 additions and 11509 deletions

View File

@@ -1,5 +1,5 @@
# ArduinoJson - https://arduinojson.org
# Copyright © 2014-2022, Benoit BLANCHON
# Copyright © 2014-2023, Benoit BLANCHON
# MIT License
add_executable(MiscTests
@@ -25,5 +25,5 @@ add_test(Misc MiscTests)
set_tests_properties(Misc
PROPERTIES
LABELS "Catch"
LABELS "Catch"
)

View File

@@ -1,11 +1,11 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson/Numbers/FloatParts.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
TEST_CASE("FloatParts<double>") {
SECTION("1.7976931348623157E+308") {

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#define ARDUINO 1

View File

@@ -1,12 +1,14 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <Arduino.h>
#include <ArduinoJson.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
#include <sstream>
using namespace ArduinoJson::detail;
TEST_CASE("Reader<std::istringstream>") {
SECTION("read()") {

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#define ARDUINOJSON_ENABLE_PROGMEM 1
@@ -14,7 +14,7 @@
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
TEST_CASE("ZeroTerminatedRamString") {
SECTION("null") {
@@ -91,13 +91,13 @@ struct EmptyStruct {};
TEST_CASE("IsString<T>") {
CHECK(IsString<std::string>::value == true);
CHECK(IsString<std::basic_string<wchar_t> >::value == false);
CHECK(IsString<std::basic_string<wchar_t>>::value == false);
CHECK(IsString<custom_string>::value == true);
CHECK(IsString<const __FlashStringHelper*>::value == true);
CHECK(IsString<const char*>::value == true);
CHECK(IsString<const char[8]>::value == true);
CHECK(IsString< ::String>::value == true);
CHECK(IsString< ::StringSumHelper>::value == true);
CHECK(IsString<::String>::value == true);
CHECK(IsString<::StringSumHelper>::value == true);
CHECK(IsString<const EmptyStruct*>::value == false);
}

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1
@@ -8,7 +8,7 @@
#include <catch.hpp>
#include "custom_string.hpp"
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
template <typename StringWriter>
static size_t print(StringWriter& writer, const char* s) {
@@ -65,7 +65,7 @@ TEST_CASE("Writer<std::string>") {
TEST_CASE("Writer<String>") {
::String output;
Writer< ::String> writer(output);
Writer<::String> writer(output);
SECTION("write(char)") {
SECTION("writes to temporary buffer") {

View File

@@ -1,11 +1,13 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
#include <sstream>
using namespace ArduinoJson::detail;
class EmptyClass {};
enum EmptyEnum {};
@@ -19,9 +21,9 @@ TEST_CASE("Polyfills/type_traits") {
}
SECTION("is_array") {
REQUIRE_FALSE((is_array<const char*>::value));
REQUIRE((is_array<const char[]>::value));
REQUIRE((is_array<const char[10]>::value));
REQUIRE_FALSE(is_array<const char*>::value);
REQUIRE(is_array<const char[]>::value);
REQUIRE(is_array<const char[10]>::value);
}
SECTION("is_const") {
@@ -172,36 +174,35 @@ TEST_CASE("Polyfills/type_traits") {
}
SECTION("is_convertible") {
CHECK((is_convertible<short, int>::value == true));
CHECK((is_convertible<int, int>::value == true));
CHECK((is_convertible<EmptyEnum, int>::value == true));
CHECK((is_convertible<int*, int>::value == false));
CHECK((is_convertible<EmptyClass, int>::value == false));
CHECK(is_convertible<short, int>::value == true);
CHECK(is_convertible<int, int>::value == true);
CHECK(is_convertible<EmptyEnum, int>::value == true);
CHECK(is_convertible<int*, int>::value == false);
CHECK(is_convertible<EmptyClass, int>::value == false);
CHECK((is_convertible<DeserializationError, JsonVariantConst>::value ==
false));
CHECK((is_convertible<JsonPair, JsonVariantConst>::value == false));
CHECK((is_convertible<JsonVariant, JsonVariantConst>::value == true));
CHECK((is_convertible<JsonVariantConst, JsonVariantConst>::value == true));
CHECK((is_convertible<JsonArray, JsonVariantConst>::value == true));
CHECK((is_convertible<ElementProxy<JsonArray>, JsonVariantConst>::value ==
true));
CHECK((is_convertible<JsonArrayConst, JsonVariantConst>::value == true));
CHECK((is_convertible<JsonObject, JsonVariantConst>::value == true));
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<DeserializationError, JsonVariantConst>::value ==
false);
CHECK(is_convertible<JsonPair, JsonVariantConst>::value == false);
CHECK(is_convertible<JsonVariant, JsonVariantConst>::value == true);
CHECK(is_convertible<JsonVariantConst, JsonVariantConst>::value == true);
CHECK(is_convertible<JsonArray, JsonVariantConst>::value == true);
CHECK(is_convertible<ElementProxy<JsonArray>, JsonVariantConst>::value ==
true);
CHECK(is_convertible<JsonArrayConst, JsonVariantConst>::value == true);
CHECK(is_convertible<JsonObject, JsonVariantConst>::value == true);
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);
}
SECTION("is_class") {
CHECK((is_class<int>::value == false));
CHECK((is_class<EmptyEnum>::value == false));
CHECK((is_class<int*>::value == false));
CHECK((is_class<EmptyClass>::value == true));
CHECK(is_class<int>::value == false);
CHECK(is_class<EmptyEnum>::value == false);
CHECK(is_class<int*>::value == false);
CHECK(is_class<EmptyClass>::value == true);
}
SECTION("is_enum") {

View File

@@ -1,11 +1,11 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson/Json/Utf16.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
static void testUtf16Codepoint(uint16_t codeunit, uint32_t expectedCodepoint) {
Utf16::Codepoint cp;

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>
@@ -7,7 +7,7 @@
#include <string>
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
static void testCodepoint(uint32_t codepoint, std::string expected) {
char buffer[4096];

View File

@@ -1,103 +1,97 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson/Numbers/arithmeticCompare.hpp>
#include <catch.hpp>
using namespace ARDUINOJSON_NAMESPACE;
using namespace ArduinoJson::detail;
TEST_CASE("arithmeticCompare()") {
SECTION("int vs uint8_t") {
CHECK((arithmeticCompare<int, uint8_t>(256, 1) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<int, uint8_t>(41, 42) == COMPARE_RESULT_LESS));
CHECK((arithmeticCompare<int, uint8_t>(42, 42) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<int, uint8_t>(43, 42) == COMPARE_RESULT_GREATER));
CHECK(arithmeticCompare<int, uint8_t>(256, 1) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<int, uint8_t>(41, 42) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompare<int, uint8_t>(42, 42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<int, uint8_t>(43, 42) == COMPARE_RESULT_GREATER);
}
SECTION("unsigned vs int") {
CHECK((arithmeticCompare<unsigned, int>(0, -1) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<unsigned, int>(42, 41) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<unsigned, int>(42, 42) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<unsigned, int>(42, 43) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<unsigned, int>(0, -1) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<unsigned, int>(42, 41) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<unsigned, int>(42, 42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<unsigned, int>(42, 43) == COMPARE_RESULT_LESS);
}
SECTION("float vs int") {
CHECK((arithmeticCompare<float, int>(42, 41) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<float, int>(42, 42) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<float, int>(42, 43) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<float, int>(42, 41) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<float, int>(42, 42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<float, int>(42, 43) == COMPARE_RESULT_LESS);
}
SECTION("int vs unsigned") {
CHECK((arithmeticCompare<int, unsigned>(-1, 0) == COMPARE_RESULT_LESS));
CHECK((arithmeticCompare<int, unsigned>(0, 0) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<int, unsigned>(1, 0) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<int, unsigned>(42, 41) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<int, unsigned>(42, 42) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<int, unsigned>(42, 43) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<int, unsigned>(-1, 0) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompare<int, unsigned>(0, 0) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<int, unsigned>(1, 0) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<int, unsigned>(42, 41) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<int, unsigned>(42, 42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<int, unsigned>(42, 43) == COMPARE_RESULT_LESS);
}
SECTION("unsigned vs unsigned") {
CHECK((arithmeticCompare<unsigned, unsigned>(42, 41) ==
COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<unsigned, unsigned>(42, 42) ==
COMPARE_RESULT_EQUAL));
CHECK(
(arithmeticCompare<unsigned, unsigned>(42, 43) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<unsigned, unsigned>(42, 41) ==
COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<unsigned, unsigned>(42, 42) ==
COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<unsigned, unsigned>(42, 43) == COMPARE_RESULT_LESS);
}
SECTION("bool vs bool") {
CHECK(
(arithmeticCompare<bool, bool>(false, false) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<bool, bool>(true, true) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<bool, bool>(false, true) == COMPARE_RESULT_LESS));
CHECK(
(arithmeticCompare<bool, bool>(true, false) == COMPARE_RESULT_GREATER));
CHECK(arithmeticCompare<bool, bool>(false, false) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<bool, bool>(true, true) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<bool, bool>(false, true) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompare<bool, bool>(true, false) == COMPARE_RESULT_GREATER);
}
SECTION("bool vs int") {
CHECK((arithmeticCompare<bool, int>(false, -1) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<bool, int>(false, 0) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<bool, int>(false, 1) == COMPARE_RESULT_LESS));
CHECK((arithmeticCompare<bool, int>(true, 0) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<bool, int>(true, 1) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<bool, int>(true, 2) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<bool, int>(false, -1) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<bool, int>(false, 0) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<bool, int>(false, 1) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompare<bool, int>(true, 0) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<bool, int>(true, 1) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<bool, int>(true, 2) == COMPARE_RESULT_LESS);
}
SECTION("bool vs int") {
CHECK((arithmeticCompare<int, bool>(0, false) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<int, bool>(1, true) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompare<int, bool>(1, false) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompare<int, bool>(0, true) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompare<int, bool>(0, false) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<int, bool>(1, true) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompare<int, bool>(1, false) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompare<int, bool>(0, true) == COMPARE_RESULT_LESS);
}
}
TEST_CASE("arithmeticCompareNegateLeft()") {
SECTION("unsigned vs int") {
CHECK((arithmeticCompareNegateLeft<int>(0, 1) == COMPARE_RESULT_LESS));
CHECK((arithmeticCompareNegateLeft<int>(42, -41) == COMPARE_RESULT_LESS));
CHECK((arithmeticCompareNegateLeft<int>(42, -42) == COMPARE_RESULT_EQUAL));
CHECK(
(arithmeticCompareNegateLeft<int>(42, -43) == COMPARE_RESULT_GREATER));
CHECK(arithmeticCompareNegateLeft<int>(0, 1) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompareNegateLeft<int>(42, -41) == COMPARE_RESULT_LESS);
CHECK(arithmeticCompareNegateLeft<int>(42, -42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompareNegateLeft<int>(42, -43) == COMPARE_RESULT_GREATER);
}
SECTION("unsigned vs unsigned") {
CHECK(
(arithmeticCompareNegateLeft<unsigned>(42, 42) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompareNegateLeft<unsigned>(42, 42) == COMPARE_RESULT_LESS);
}
}
TEST_CASE("arithmeticCompareNegateRight()") {
SECTION("int vs unsigned") {
CHECK((arithmeticCompareNegateRight<int>(1, 0) == COMPARE_RESULT_GREATER));
CHECK(
(arithmeticCompareNegateRight<int>(-41, 42) == COMPARE_RESULT_GREATER));
CHECK((arithmeticCompareNegateRight<int>(-42, 42) == COMPARE_RESULT_EQUAL));
CHECK((arithmeticCompareNegateRight<int>(-43, 42) == COMPARE_RESULT_LESS));
CHECK(arithmeticCompareNegateRight<int>(1, 0) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompareNegateRight<int>(-41, 42) == COMPARE_RESULT_GREATER);
CHECK(arithmeticCompareNegateRight<int>(-42, 42) == COMPARE_RESULT_EQUAL);
CHECK(arithmeticCompareNegateRight<int>(-43, 42) == COMPARE_RESULT_LESS);
}
SECTION("unsigned vs unsigned") {
CHECK((arithmeticCompareNegateRight<unsigned>(42, 42) ==
COMPARE_RESULT_GREATER));
CHECK(arithmeticCompareNegateRight<unsigned>(42, 42) ==
COMPARE_RESULT_GREATER);
}
}

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
// Include any header that might use the conflicting macros

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#pragma once

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <Arduino.h>

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson.h>

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson/version.hpp>

View File

@@ -1,5 +1,5 @@
// ArduinoJson - https://arduinojson.org
// Copyright © 2014-2022, Benoit BLANCHON
// Copyright © 2014-2023, Benoit BLANCHON
// MIT License
#include <ArduinoJson/Namespace.hpp>
@@ -8,7 +8,8 @@
// Issue #1198: strcmp() implementation that returns a value larger than 8-bit
namespace ARDUINOJSON_NAMESPACE {
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
int strcmp(const char* a, const char* b) {
int result = ::strcmp(a, b);
if (result > 0)
@@ -26,4 +27,5 @@ int strncmp(const char* a, const char* b, size_t n) {
return -214748364;
return 0;
}
} // namespace ARDUINOJSON_NAMESPACE
ARDUINOJSON_END_PRIVATE_NAMESPACE