Skip to content

Commit f7e3241

Browse files
committed
Add test case for invalid copy
1 parent 3d30942 commit f7e3241

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/src/String/test_operators.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,28 @@ TEST_CASE ("Testing & String::operator = (StringSumHelper &&rval)", "[String-ope
112112
arduino::String str = (str1+ch);
113113
REQUIRE(str.compareTo("Hello!") == 0);
114114
*/
115+
}
116+
117+
TEST_CASE ("Testing & String::operator = (const String &)", "[String-operator+-13]")
118+
{
119+
char *buffer1 = (char *)malloc(sizeof("Hello"));
120+
strcpy(buffer1, "Hello");
121+
arduino::String str1(buffer1);
122+
123+
char *buffer2 = (char *)malloc(sizeof("Hello"));
124+
strcpy(buffer2, "Hello");
125+
arduino::String str2(buffer2);
126+
127+
//buffer2 = (char *)realloc(buffer, 0);
128+
free(buffer2);
129+
//arduino::String str1("Hello");
130+
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+
*/
115139
}

0 commit comments

Comments
 (0)