forked from arduino/ArduinoCore-API
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_substring.cpp
More file actions
42 lines (34 loc) · 1.06 KB
/
test_substring.cpp
File metadata and controls
42 lines (34 loc) · 1.06 KB
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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch2/catch_test_macros.hpp>
#include <api/String.h>
#include "StringPrinter.h"
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing String::substring(unsigned int, unsigned int)", "[String-substring-01]")
{
WHEN ("left higher than len")
{
arduino::String str("Hello");
str.substring(7,9);
}
WHEN ("right higher than len")
{
arduino::String str1("Hello");
arduino::String str2("ello");
REQUIRE(str2 == str1.substring(1,9));
}
WHEN ("left higher than right")
{
arduino::String str1("Hello");
arduino::String str2("ello");
REQUIRE(str2 == str1.substring(9,1));
}
}