Skip to content

Commit 0eaaf5e

Browse files
committed
Add test case to invalidate & String::operator = (const String &rhs)
1 parent 8ad3bde commit 0eaaf5e

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

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

+4-16
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,14 @@ TEST_CASE ("Testing & String::operator = (StringSumHelper &&rval)", "[String-ope
116116

117117
TEST_CASE ("Testing & String::operator = (const String &)", "[String-operator+-13]")
118118
{
119-
char *buffer1 = (char *)malloc(sizeof("Hello"));
120-
strcpy(buffer1, "Hello");
121-
arduino::String str1(buffer1);
119+
arduino::String str1("Hello");
120+
121+
char *buffer2 = NULL;
122122

123-
char *buffer2 = (char *)malloc(sizeof("Hello"));
124-
strcpy(buffer2, "Hello");
125123
arduino::String str2(buffer2);
126124

127-
//buffer2 = (char *)realloc(buffer, 0);
128-
free(buffer2);
129-
//arduino::String str1("Hello");
130125
str1 = str2;
131-
REQUIRE(str1.compareTo("Hello") == 0);
132-
free(buffer1);
133-
/*
134-
arduino::String str1;
135-
char ch='!';
136-
arduino::String str = (str1+ch);
137-
REQUIRE(str.compareTo("Hello!") == 0);
138-
*/
126+
REQUIRE(str1.compareTo(str2) == 0);
139127
}
140128

141129
TEST_CASE ("Testing & String::operator = (const char *)", "[String-operator+-14]")

0 commit comments

Comments
 (0)