File tree 2 files changed +38
-0
lines changed
2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ set(TEST_SRCS
66
66
src/String /test_indexOf.cpp
67
67
src/String /test_lastIndexOf.cpp
68
68
src/String /test_length.cpp
69
+ src/String /test_move.cpp
69
70
src/String /test_remove.cpp
70
71
src/String /test_replace.cpp
71
72
src/String /test_String.cpp
Original file line number Diff line number Diff line change
1
+ #include < catch.hpp>
2
+
3
+ #include < String.h>
4
+
5
+ #include " StringPrinter.h"
6
+
7
+ #include < utility>
8
+
9
+ TEST_CASE (" Testing String move constructor" , " [String-move-01]" )
10
+ {
11
+ arduino::String a (" src" );
12
+ char const * const a_str = a.c_str ();
13
+ arduino::String b (std::move (a));
14
+ REQUIRE (a.length () == 0 );
15
+ REQUIRE (a.c_str () == nullptr );
16
+ REQUIRE (b.c_str () == a_str);
17
+ REQUIRE (b.length () == 3 );
18
+ }
19
+
20
+ TEST_CASE (" Testing String move assignment" , " [String-move-02]" )
21
+ {
22
+ arduino::String a (" src" );
23
+ char const * const a_str = a.c_str ();
24
+ arduino::String b;
25
+ b = std::move (a);
26
+ REQUIRE (a.length () == 0 );
27
+ REQUIRE (a.c_str () == nullptr );
28
+ REQUIRE (b == arduino::String (" src" ));
29
+ REQUIRE (b.c_str () == a_str);
30
+ }
31
+
32
+ TEST_CASE (" Testing String move self assignment" , " [String-move-03]" )
33
+ {
34
+ arduino::String a (" src" );
35
+ a = std::move (a);
36
+ REQUIRE (a == " src" );
37
+ }
You can’t perform that action at this time.
0 commit comments