Skip to content

Commit 6d9db81

Browse files
committed
Test String(const __FlashStringHelper) constructor() with invalid buffer
1 parent d2c8b2e commit 6d9db81

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test/src/String/test_String.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,13 @@ TEST_CASE ("Testing String(double, unsigned char decimalPlaces = 2) constructor(
9191
arduino::String str(val);
9292
REQUIRE(strcmp(str.c_str(), "5.68") == 0);
9393
}
94+
95+
TEST_CASE ("Testing String(const __FlashStringHelper) constructor() with invalid buffer", "[String-Ctor-12]")
96+
{
97+
#undef F
98+
#define F(string_literal) (reinterpret_cast<const arduino::__FlashStringHelper *>(PSTR(string_literal)))
99+
char *buffer = NULL;
100+
101+
arduino::String str1(F(buffer));
102+
REQUIRE(str1.compareTo("Hello") == 0);
103+
}

0 commit comments

Comments
 (0)