|
| 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::remove(index) when string is empty", "[String-remove-01]") |
| 18 | +{ |
| 19 | + arduino::String str; |
| 20 | + str.remove(0); |
| 21 | + REQUIRE(str.length() == 0); |
| 22 | +} |
| 23 | + |
| 24 | +TEST_CASE ("Testing String::remove(index) when index is > string length", "[String-remove-02]") |
| 25 | +{ |
| 26 | + arduino::String str("Hello Arduino!"); |
| 27 | + str.remove(100); |
| 28 | + REQUIRE(strcmp(str.c_str(), "Hello Arduino!") == 0); |
| 29 | +} |
| 30 | + |
| 31 | +TEST_CASE ("Testing String::remove(index) when index is < string length", "[String-remove-03]") |
| 32 | +{ |
| 33 | + arduino::String str("Hello Arduino!"); |
| 34 | + str.remove(5); |
| 35 | + REQUIRE(strcmp(str.c_str(), "Hello") == 0); |
| 36 | +} |
| 37 | + |
| 38 | +TEST_CASE ("Testing String::remove(index,count) when string is empty", "[String-remove-04]") |
| 39 | +{ |
| 40 | + arduino::String str; |
| 41 | + str.remove(0, 10); |
| 42 | + REQUIRE(str.length() == 0); |
| 43 | +} |
| 44 | + |
| 45 | +TEST_CASE ("Testing String::remove(index,count) when index is > string length", "[String-remove-05]") |
| 46 | +{ |
| 47 | + arduino::String str("Hello Arduino!"); |
| 48 | + str.remove(100, 10); |
| 49 | + REQUIRE(strcmp(str.c_str(), "Hello Arduino!") == 0); |
| 50 | +} |
| 51 | + |
| 52 | +TEST_CASE ("Testing String::remove(index,count) when index is < string length && count is > remaining length", "[String-remove-06]") |
| 53 | +{ |
| 54 | + arduino::String str("Hello Arduino!"); |
| 55 | + str.remove(5, 100); |
| 56 | + REQUIRE(strcmp(str.c_str(), "Hello") == 0); |
| 57 | +} |
| 58 | + |
| 59 | +TEST_CASE ("Testing String::remove(index,count) when index is < string length && count is < remaining length", "[String-remove-07]") |
| 60 | +{ |
| 61 | + arduino::String str("Hello Arduino!"); |
| 62 | + str.remove(5, 1); |
| 63 | + REQUIRE(strcmp(str.c_str(), "HelloArduino!") == 0); |
| 64 | +} |
0 commit comments