1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

WString: c_str() returns null pointer after move (#7611)

* (test) WString: c_str() returns null pointer

target = std::move(source) does not reset buffer pointer back to the sso

* wstring: correctly do move invalidation & copy

based on the #7553 without isSSO -> isHeap rename and inline optimizations
additionally, remove useless pre-c++11 preprocessor checks

Co-authored-by: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
This commit is contained in:
Max Prokhorov
2020-09-27 18:11:52 +03:00
committed by GitHub
parent a3281fe2f3
commit cc042b99d1
3 changed files with 20 additions and 39 deletions

View File

@ -19,6 +19,19 @@
#include <limits.h>
#include <StreamString.h>
TEST_CASE("String::move", "[core][String]")
{
const char buffer[] = "this string goes over the sso limit";
String target;
String source(buffer);
target = std::move(source);
REQUIRE(source.c_str() != nullptr);
REQUIRE(!source.length());
REQUIRE(target == buffer);
}
TEST_CASE("String::trim", "[core][String]")
{
String str;