forked from bblanchon/ArduinoJson
Reference-count shared strings
This commit is contained in:
1 parent
b7c8e0d25c
commit
003087406c
9 files changed
+131
-24
No files matched your search
@@ -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