Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fee6567

Browse filesBrowse files
committed
Add tests for String move
1 parent 14e923e commit fee6567
Copy full SHA for fee6567

File tree

2 files changed

+38
-0
lines changed
Filter options

2 files changed

+38
-0
lines changed

‎test/CMakeLists.txt

Copy file name to clipboardExpand all lines: test/CMakeLists.txt
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set(TEST_SRCS
6666
src/String/test_indexOf.cpp
6767
src/String/test_lastIndexOf.cpp
6868
src/String/test_length.cpp
69+
src/String/test_move.cpp
6970
src/String/test_remove.cpp
7071
src/String/test_replace.cpp
7172
src/String/test_String.cpp

‎test/src/String/test_move.cpp

Copy file name to clipboard
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.