-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_trim.cpp
43 lines (35 loc) · 1.2 KB
/
test_trim.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
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <String.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing String::trim with space at the beginning", "[String-trim-01]")
{
arduino::String str(" hello");
str.trim();
REQUIRE(strcmp(str.c_str(), "hello") == 0);
}
TEST_CASE ("Testing String::trim with space at the end", "[String-trim-02]")
{
arduino::String str("hello ");
str.trim();
REQUIRE(strcmp(str.c_str(), "hello") == 0);
}
TEST_CASE ("Testing String::trim with space at both beginng and end", "[String-trim-03]")
{
arduino::String str(" hello ");
str.trim();
REQUIRE(strcmp(str.c_str(), "hello") == 0);
}
TEST_CASE ("Testing String::trim with space in the middle", "[String-trim-04]")
{
arduino::String str("Hello Arduino!");
str.trim();
REQUIRE(strcmp(str.c_str(), "Hello Arduino!") == 0);
}