File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ set(TEST_SRCS
46
46
src/String /test_length.cpp
47
47
src/String /test_replace.cpp
48
48
src/String /test_String.cpp
49
+ src/String /test_toInt.cpp
49
50
src/String /test_toLowerCase.cpp
50
51
src/String /test_toUpperCase.cpp
51
52
src/String /test_trim.cpp
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2020 Arduino. All rights reserved.
3
+ */
4
+
5
+ /* *************************************************************************************
6
+ * INCLUDE
7
+ **************************************************************************************/
8
+
9
+ #include < catch.hpp>
10
+
11
+ #include < String.h>
12
+
13
+ /* *************************************************************************************
14
+ * TEST CODE
15
+ **************************************************************************************/
16
+
17
+ TEST_CASE (" Testing String::toInt when string is empty" , " [String-toInt-01]" )
18
+ {
19
+ arduino::String str;
20
+ int const val = str.toInt ();
21
+ REQUIRE (val == 0 );
22
+ }
23
+
24
+ TEST_CASE (" Testing String::toInt when string contains no number" , " [String-toInt-02]" )
25
+ {
26
+ arduino::String str (" abc" );
27
+ int const val = str.toInt ();
28
+ REQUIRE (val == 0 );
29
+ }
30
+
31
+ TEST_CASE (" Testing String::toInt when string contains a number" , " [String-toInt-03]" )
32
+ {
33
+ arduino::String str (" -1" );
34
+ int const val = str.toInt ();
35
+ REQUIRE (val == -1 );
36
+ }
You can’t perform that action at this time.
0 commit comments