Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7deb046

Browse files
Add more tests for assigning (to) invalid Strings
1 parente4c65c1 commit7deb046

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

‎test/src/String/test_operators.cpp‎

Lines changed: 21 additions & 2 deletions
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::Stringstr("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::Stringstr("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::Stringstr1(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::Stringstr1(buffer1);
155+
156+
arduino::Stringstr2("Hello");
157+
158+
str1 = str2;
159+
REQUIRE(str1);
160+
}
161+
143162
TEST_CASE ("Testing & String::operator = (String &&)","[String-operator+-16]")
144163
{
145164
arduino::Stringstr("Hello");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp