-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathtest_insert.cpp
47 lines (36 loc) · 1.35 KB
/
test_insert.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
/*
* Copyright (c) 2023 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <String.h>
#include "StringPrinter.h"
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing String::insert(char, index)", "[String-insert-01]")
{
arduino::String str = "ello";
str.insert('h', 0);
REQUIRE(str == String("hello"));
}
TEST_CASE ("Testing String::insert(char, index) with index > length", "[String-insert-02]")
{
arduino::String str = "Hello Arduino";
str.insert('!', str.length() + 1);
REQUIRE(str == String("Hello Arduino"));
}
TEST_CASE ("Testing String::insert(String, index, length) with length >= inserted length", "[String-insert-03]")
{
arduino::String str = "hello ";
str.insert("world", str.length(), 5);
REQUIRE(str == String("hello world"));
}
TEST_CASE ("Testing String::insert(String, index, length) with length < inserted length", "[String-insert-04]")
{
arduino::String str = "Hello ";
str.insert("Arduino 1234", str.length(), 7);
REQUIRE(str == String("Hello Arduino"));
}