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

Commita7e0931

Browse files
committed
Adding test code for Stream::findUntil(...)
1 parent08a44c9 commita7e0931

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

‎test/CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ set(TEST_SRCS
4848
src/Ringbuffer/test_read_char.cpp
4949
src/Ringbuffer/test_store_char.cpp
5050
src/Stream/test_find.cpp
51+
src/Stream/test_findUntil.cpp
5152
src/Stream/test_getTimeout.cpp
5253
src/Stream/test_readString.cpp
5354
src/Stream/test_readStringUntil.cpp

‎test/src/Stream/test_findUntil.cpp‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2020 Arduino. All rights reserved.
3+
*/
4+
5+
/**************************************************************************************
6+
* INCLUDE
7+
**************************************************************************************/
8+
9+
#include<catch.hpp>
10+
11+
#include<StreamMock.h>
12+
13+
/**************************************************************************************
14+
* TEST CODE
15+
**************************************************************************************/
16+
17+
TEST_CASE ("Testing findUntil(const char *target, const char *terminator)","[Stream-findUntil-01]")
18+
{
19+
StreamMock mock;
20+
21+
WHEN ("'target' is contained in stream")
22+
{
23+
WHEN ("'terminator' appears before 'target'")
24+
{
25+
mock <<"This is a : test string";
26+
REQUIRE(mock.findUntil("test",":") ==false);
27+
REQUIRE(mock.readString() ==arduino::String("test string"));
28+
}
29+
WHEN ("'terminator' appears after 'target'")
30+
{
31+
mock <<"This is a test : string";
32+
REQUIRE(mock.findUntil("test",":") ==true);
33+
REQUIRE(mock.readString() ==arduino::String(" : string"));
34+
}
35+
WHEN ("'terminator' is not included in the string at all")
36+
{
37+
mock <<"This is a test string";
38+
REQUIRE(mock.findUntil("test",":") ==true);
39+
REQUIRE(mock.readString() ==arduino::String(" string"));
40+
}
41+
}
42+
43+
WHEN ("'target' is not contained in stream")
44+
{
45+
mock <<"This is a test string";
46+
REQUIRE(mock.findUntil("abc","def") ==false);
47+
REQUIRE(mock.readString() ==arduino::String(""));
48+
}
49+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp