-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_remove.cpp
66 lines (54 loc) · 1.85 KB
/
test_remove.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <String.h>
#include "StringPrinter.h"
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing String::remove(index) when string is empty", "[String-remove-01]")
{
arduino::String str;
str.remove(0);
REQUIRE(str.length() == 0);
}
TEST_CASE ("Testing String::remove(index) when index is > string length", "[String-remove-02]")
{
arduino::String str("Hello Arduino!");
str.remove(100);
REQUIRE(str == "Hello Arduino!");
}
TEST_CASE ("Testing String::remove(index) when index is < string length", "[String-remove-03]")
{
arduino::String str("Hello Arduino!");
str.remove(5);
REQUIRE(str == "Hello");
}
TEST_CASE ("Testing String::remove(index,count) when string is empty", "[String-remove-04]")
{
arduino::String str;
str.remove(0, 10);
REQUIRE(str.length() == 0);
}
TEST_CASE ("Testing String::remove(index,count) when index is > string length", "[String-remove-05]")
{
arduino::String str("Hello Arduino!");
str.remove(100, 10);
REQUIRE(str == "Hello Arduino!");
}
TEST_CASE ("Testing String::remove(index,count) when index is < string length && count is > remaining length", "[String-remove-06]")
{
arduino::String str("Hello Arduino!");
str.remove(5, 100);
REQUIRE(str == "Hello");
}
TEST_CASE ("Testing String::remove(index,count) when index is < string length && count is < remaining length", "[String-remove-07]")
{
arduino::String str("Hello Arduino!");
str.remove(5, 1);
REQUIRE(str == "HelloArduino!");
}