mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-23 07:17:30 +02:00
Remove ARDUINOJSON_ENABLE_STRING_DEDUPLICATION
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
using ArduinoJson::detail::sizeofObject;
|
||||
using ArduinoJson::detail::sizeofString;
|
||||
|
||||
@ -133,3 +134,22 @@ TEST_CASE("Empty memory pool") {
|
||||
REQUIRE(deserializeJson(doc, empty) == DeserializationError::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Deduplicate values") {
|
||||
JsonDocument doc(1024);
|
||||
deserializeJson(doc, "[\"example\",\"example\"]");
|
||||
|
||||
CHECK(doc.memoryUsage() == sizeofArray(2) + 8);
|
||||
CHECK(doc[0].as<const char*>() == doc[1].as<const char*>());
|
||||
}
|
||||
|
||||
TEST_CASE("Deduplicate keys") {
|
||||
JsonDocument doc(1024);
|
||||
deserializeJson(doc, "[{\"example\":1},{\"example\":2}]");
|
||||
|
||||
CHECK(doc.memoryUsage() == 2 * sizeofObject(1) + sizeofArray(2) + 8);
|
||||
|
||||
const char* key1 = doc[0].as<JsonObject>().begin()->key().c_str();
|
||||
const char* key2 = doc[1].as<JsonObject>().begin()->key().c_str();
|
||||
CHECK(key1 == key2);
|
||||
}
|
||||
|
Reference in New Issue
Block a user