Skip to content

Commit d2c8b2e

Browse files
committed
Add test code for & String::operator[]
1 parent 73550eb commit d2c8b2e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test/src/String/test_characterAccessFunc.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,18 @@ TEST_CASE ("Testing String::getBytes(unsigned char, unsigned int, unsigned int)"
4949
REQUIRE(buf[1] == 'o');
5050
}
5151
}
52+
53+
TEST_CASE ("Testing & String::operator[]", "[String-&operator[]-03]")
54+
{
55+
arduino::String str("Hello");
56+
str[0] = 'M';
57+
REQUIRE(str == "Mello");
58+
}
59+
60+
TEST_CASE ("Testing & String::operator[] with invalid buffer", "[String-&operator[]-04]")
61+
{
62+
char *buffer = NULL;
63+
arduino::String str(buffer);
64+
str[0] = 'M';
65+
REQUIRE(str[0] == 0);
66+
}

0 commit comments

Comments
 (0)