Skip to content

Commit 9045a94

Browse files
committed
Adding test code for String::length
1 parent 4c41f0b commit 9045a94

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set(TEST_SRCS
4242
src/Ringbuffer/test_peek.cpp
4343
src/Ringbuffer/test_read_char.cpp
4444
src/Ringbuffer/test_store_char.cpp
45+
src/String/test_length.cpp
4546
src/String/test_String.cpp
4647
src/WCharacter/test_isControl.cpp
4748
src/WCharacter/test_isDigit.cpp

test/src/String/test_length.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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::length when string is empty", "[String-length-01]")
18+
{
19+
arduino::String str;
20+
REQUIRE(str.length() == 0);
21+
}
22+
23+
TEST_CASE ("Testing String::length when string contains characters", "[String-length-02]")
24+
{
25+
arduino::String str("Testing String::length");
26+
REQUIRE(str.length() == strlen("Testing String::length"));
27+
}

0 commit comments

Comments
 (0)