-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_move.cpp
37 lines (31 loc) · 909 Bytes
/
test_move.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <catch.hpp>
#include <String.h>
#include "StringPrinter.h"
#include <utility>
TEST_CASE("Testing String move constructor", "[String-move-01]")
{
arduino::String a("src");
char const* const a_str = a.c_str();
arduino::String b(std::move(a));
REQUIRE(a.length() == 0);
REQUIRE(a.c_str() == nullptr);
REQUIRE(b.c_str() == a_str);
REQUIRE(b.length() == 3);
}
TEST_CASE("Testing String move assignment", "[String-move-02]")
{
arduino::String a("src");
char const* const a_str = a.c_str();
arduino::String b;
b = std::move(a);
REQUIRE(a.length() == 0);
REQUIRE(a.c_str() == nullptr);
REQUIRE(b == arduino::String("src"));
REQUIRE(b.c_str() == a_str);
}
TEST_CASE("Testing String move self assignment", "[String-move-03]")
{
arduino::String a("src");
a = std::move(a);
REQUIRE(a == "src");
}