mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-23 23:37:37 +02:00
Reference-count shared strings
This commit is contained in:
@ -6,6 +6,9 @@
|
||||
#include <stdint.h>
|
||||
#include <catch.hpp>
|
||||
|
||||
using ArduinoJson::detail::sizeofArray;
|
||||
using ArduinoJson::detail::sizeofString;
|
||||
|
||||
TEST_CASE("JsonVariant::clear()") {
|
||||
JsonDocument doc(4096);
|
||||
JsonVariant var = doc.to<JsonVariant>();
|
||||
@ -23,4 +26,12 @@ TEST_CASE("JsonVariant::clear()") {
|
||||
|
||||
REQUIRE(var.isNull() == true);
|
||||
}
|
||||
|
||||
SECTION("releases owned string") {
|
||||
var.set(std::string("hello"));
|
||||
REQUIRE(doc.memoryUsage() == sizeofString(5));
|
||||
|
||||
var.clear();
|
||||
REQUIRE(doc.memoryUsage() == 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user