forked from bblanchon/ArduinoJson
Change string copy policy: only string literal are stored by pointer
This commit is contained in:
@ -26,7 +26,7 @@ TEST_CASE("JsonDocument::add(T)") {
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("const char*") {
|
||||
SECTION("string literal") {
|
||||
doc.add("hello");
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[\"hello\"]");
|
||||
@ -35,6 +35,17 @@ TEST_CASE("JsonDocument::add(T)") {
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("const char*") {
|
||||
const char* value = "hello";
|
||||
doc.add(value);
|
||||
|
||||
REQUIRE(doc.as<std::string>() == "[\"hello\"]");
|
||||
REQUIRE(spy.log() == AllocatorLog{
|
||||
Allocate(sizeofPool()),
|
||||
Allocate(sizeofString("hello")),
|
||||
});
|
||||
}
|
||||
|
||||
SECTION("std::string") {
|
||||
doc.add("example"_s);
|
||||
doc.add("example"_s);
|
||||
|
Reference in New Issue
Block a user