|
| 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 | +} |