mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 02:37:35 +02:00
Remove JSON_ARRAY_SIZE()
, JSON_OBJECT_SIZE()
, and JSON_STRING_SIZE()
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
|
||||
TEST_CASE("JsonDocument::overflowed()") {
|
||||
SECTION("returns false on a fresh object") {
|
||||
JsonDocument doc(0);
|
||||
@ -18,19 +20,19 @@ TEST_CASE("JsonDocument::overflowed()") {
|
||||
}
|
||||
|
||||
SECTION("returns false after successful insertion") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
doc.add(0);
|
||||
CHECK(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("returns true after a failed string copy") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
doc.add(std::string("example"));
|
||||
CHECK(doc.overflowed() == true);
|
||||
}
|
||||
|
||||
SECTION("returns false after a successful string copy") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
|
||||
JsonDocument doc(sizeofArray(1) + 8);
|
||||
doc.add(std::string("example"));
|
||||
CHECK(doc.overflowed() == false);
|
||||
}
|
||||
@ -42,13 +44,13 @@ TEST_CASE("JsonDocument::overflowed()") {
|
||||
}
|
||||
|
||||
SECTION("returns true after a failed deserialization") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
deserializeJson(doc, "[\"example\"]");
|
||||
CHECK(doc.overflowed() == true);
|
||||
}
|
||||
|
||||
SECTION("returns false after a successful deserialization") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1) + 8);
|
||||
JsonDocument doc(sizeofArray(1) + 8);
|
||||
deserializeJson(doc, "[\"example\"]");
|
||||
CHECK(doc.overflowed() == false);
|
||||
}
|
||||
@ -61,14 +63,14 @@ TEST_CASE("JsonDocument::overflowed()") {
|
||||
}
|
||||
|
||||
SECTION("remains false after shrinkToFit()") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
doc.add(0);
|
||||
doc.shrinkToFit();
|
||||
CHECK(doc.overflowed() == false);
|
||||
}
|
||||
|
||||
SECTION("remains true after shrinkToFit()") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
doc.add(0);
|
||||
doc.add(0);
|
||||
doc.shrinkToFit();
|
||||
@ -76,7 +78,7 @@ TEST_CASE("JsonDocument::overflowed()") {
|
||||
}
|
||||
|
||||
SECTION("return false after garbageCollect()") {
|
||||
JsonDocument doc(JSON_ARRAY_SIZE(1));
|
||||
JsonDocument doc(sizeofArray(1));
|
||||
doc.add(0);
|
||||
doc.add(0);
|
||||
doc.garbageCollect();
|
||||
|
Reference in New Issue
Block a user