Skip to content

Commit 7deb046

Browse files
Add more tests for assigning (to) invalid Strings
1 parent e4c65c1 commit 7deb046

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Diff for: test/src/String/test_operators.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,23 @@ TEST_CASE ("Testing & String::operator = (const String &) with invalid buffer of
121121
REQUIRE(str1.compareTo(str2) == 0);
122122
}
123123

124-
TEST_CASE ("Testing & String::operator = (const char *)", "[String-operator+-14]")
124+
TEST_CASE ("Testing & String::operator = (const char *) with NULL does not leave string unchanged", "[String-operator+-14]")
125125
{
126126
char *buffer = NULL;
127127
arduino::String str("Hello");
128128
str = buffer;
129129
REQUIRE(str.compareTo("Hello") != 0);
130130
}
131131

132-
TEST_CASE ("Testing & String::operator = (const String &) with invalid buffer of first string", "[String-operator+-15]")
132+
TEST_CASE ("Testing & String::operator = (const char *) with NULL produces invalid string", "[String-operator+-14]")
133+
{
134+
char *buffer = NULL;
135+
arduino::String str("Hello");
136+
str = buffer;
137+
REQUIRE_FALSE(str);
138+
}
139+
140+
TEST_CASE ("Testing & String::operator = (const String &) on invalid String updates it", "[String-operator+-15]")
133141
{
134142
char *buffer1 = NULL;
135143
arduino::String str1(buffer1);
@@ -140,6 +148,17 @@ TEST_CASE ("Testing & String::operator = (const String &) with invalid buffer of
140148
REQUIRE(str1.compareTo(str2) == 0);
141149
}
142150

151+
TEST_CASE ("Testing & String::operator = (const String &) on invalid String makes it valid", "[String-operator+-15]")
152+
{
153+
char *buffer1 = NULL;
154+
arduino::String str1(buffer1);
155+
156+
arduino::String str2("Hello");
157+
158+
str1 = str2;
159+
REQUIRE(str1);
160+
}
161+
143162
TEST_CASE ("Testing & String::operator = (String &&)", "[String-operator+-16]")
144163
{
145164
arduino::String str("Hello");

0 commit comments

Comments
 (0)