Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit41599a3

Browse files
committed
Add tests for String move
1 parent9668aa6 commit41599a3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

‎test/CMakeLists.txt

Lines 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

Lines 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::Stringa("src");
12+
charconst*const a_str = a.c_str();
13+
arduino::Stringb(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::Stringa("src");
23+
charconst*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::Stringa("src");
35+
a =std::move(a);
36+
REQUIRE(a =="src");
37+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp