File tree 2 files changed +30
-0
lines changed
2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ class String
89
89
// invalid string (i.e., "if (s)" will be true afterwards)
90
90
bool reserve (unsigned int size);
91
91
inline unsigned int length (void ) const {return len;}
92
+ inline bool isEmpty (void ) const { return length () == 0 ; }
92
93
93
94
// creates a copy of the assigned value. if the value is null or
94
95
// invalid, or if the memory allocation fails, the string will be
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023 Arduino. All rights reserved.
3
+ */
4
+
5
+ /* *************************************************************************************
6
+ * INCLUDE
7
+ **************************************************************************************/
8
+
9
+ #include < catch.hpp>
10
+
11
+ #include < api/String.h>
12
+
13
+ #include " StringPrinter.h"
14
+
15
+ /* *************************************************************************************
16
+ * TEST CODE
17
+ **************************************************************************************/
18
+
19
+ TEST_CASE (" Testing String::isEmpty when string is empty" , " [String-isEmpty-01]" )
20
+ {
21
+ arduino::String str;
22
+ REQUIRE (str.isEmpty ());
23
+ }
24
+
25
+ TEST_CASE (" Testing String::isEmpty when string contains characters" , " [String-isEmpty-02]" )
26
+ {
27
+ arduino::String str (" Testing String::isEmpty" );
28
+ REQUIRE (!str.isEmpty ());
29
+ }
You can’t perform that action at this time.
0 commit comments