Don't store string literals by pointer anymore

Fixes #2189
This commit is contained in:
Benoit Blanchon
2025-08-28 10:04:11 +02:00
parent 509807d3c2
commit dddc4912c4
30 changed files with 174 additions and 331 deletions

View File

@@ -137,11 +137,12 @@ TEST_CASE("serialize MsgPack value") {
checkVariant(longest.c_str(), "\xDA\xFF\xFF"_s + longest);
}
#if ARDUINOJSON_STRING_LENGTH_SIZE > 2
SECTION("str 32") {
std::string shortest(65536, '?');
checkVariant(JsonString(shortest.c_str(), true), // force store by pointer
"\xDB\x00\x01\x00\x00"_s + shortest);
checkVariant(shortest.c_str(), "\xDB\x00\x01\x00\x00"_s + shortest);
}
#endif
SECTION("serialized(const char*)") {
checkVariant(serialized("\xDA\xFF\xFF"), "\xDA\xFF\xFF");