Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit336ce65

Browse files
committed
Adding test code for String::trim
1 parentbf77b48 commit336ce65

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

‎test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(TEST_SRCS
4747
src/String/test_String.cpp
4848
src/String/test_toLowerCase.cpp
4949
src/String/test_toUpperCase.cpp
50+
src/String/test_trim.cpp
5051
src/WCharacter/test_isControl.cpp
5152
src/WCharacter/test_isDigit.cpp
5253
src/WCharacter/test_isHexadecimalDigit.cpp

‎test/src/String/test_trim.cpp‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include<catch.hpp>
10+
11+
#include<String.h>
12+
13+
/**************************************************************************************
14+
* TEST CODE
15+
**************************************************************************************/
16+
17+
TEST_CASE ("Testing String::trim with space at the beginning","[String-trim-01]")
18+
{
19+
arduino::Stringstr(" hello");
20+
str.trim();
21+
REQUIRE(strcmp(str.c_str(),"hello") ==0);
22+
}
23+
24+
TEST_CASE ("Testing String::trim with space at the end","[String-trim-02]")
25+
{
26+
arduino::Stringstr("hello");
27+
str.trim();
28+
REQUIRE(strcmp(str.c_str(),"hello") ==0);
29+
}
30+
31+
TEST_CASE ("Testing String::trim with space at both beginng and end","[String-trim-03]")
32+
{
33+
arduino::Stringstr(" hello");
34+
str.trim();
35+
REQUIRE(strcmp(str.c_str(),"hello") ==0);
36+
}
37+
38+
TEST_CASE ("Testing String::trim with space in the middle","[String-trim-04]")
39+
{
40+
arduino::Stringstr("Hello Arduino!");
41+
str.trim();
42+
REQUIRE(strcmp(str.c_str(),"Hello Arduino!") ==0);
43+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp