Skip to content

Commit 73550eb

Browse files
committed
Add test cases for String::toInt() and String::toDouble() with invalid buffer
1 parent 1cf220b commit 73550eb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

test/src/String/test_toDouble.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ TEST_CASE ("Testing String::toDouble when string contains a number", "[String-to
3434
double const val = str.toDouble();
3535
REQUIRE(val == -1.2345);
3636
}
37+
38+
TEST_CASE ("Testing String::toDouble when string does not have a buffer", "[String-toDouble-04]")
39+
{
40+
char *buffer = NULL;
41+
arduino::String str(buffer);
42+
REQUIRE(str.toDouble() == 0);
43+
}

test/src/String/test_toInt.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ TEST_CASE ("Testing String::toInt when string contains a number", "[String-toInt
3434
int const val = str.toInt();
3535
REQUIRE(val == -1);
3636
}
37+
38+
TEST_CASE ("Testing String::toInt when string does not have a buffer", "[String-toInt-04]")
39+
{
40+
char *buffer = NULL;
41+
arduino::String str(buffer);
42+
REQUIRE(str.toInt() == 0);
43+
}

0 commit comments

Comments
 (0)