-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathtest_findUntil.cpp
49 lines (42 loc) · 1.5 KB
/
test_findUntil.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Copyright (c) 2020 Arduino. All rights reserved.
*/
/**************************************************************************************
* INCLUDE
**************************************************************************************/
#include <catch.hpp>
#include <StreamMock.h>
/**************************************************************************************
* TEST CODE
**************************************************************************************/
TEST_CASE ("Testing findUntil(const char *target, const char *terminator)", "[Stream-findUntil-01]")
{
StreamMock mock;
WHEN ("'target' is contained in stream")
{
WHEN ("'terminator' appears before 'target'")
{
mock << "This is a : test string";
REQUIRE(mock.findUntil("test", ": ") == false);
REQUIRE(mock.readString() == arduino::String("test string"));
}
WHEN ("'terminator' appears after 'target'")
{
mock << "This is a test : string";
REQUIRE(mock.findUntil("test", ": ") == true);
REQUIRE(mock.readString() == arduino::String(" : string"));
}
WHEN ("'terminator' is not included in the string at all")
{
mock << "This is a test string";
REQUIRE(mock.findUntil("test", ": ") == true);
REQUIRE(mock.readString() == arduino::String(" string"));
}
}
WHEN ("'target' is not contained in stream")
{
mock << "This is a test string";
REQUIRE(mock.findUntil("abc", "def") == false);
REQUIRE(mock.readString() == arduino::String(""));
}
}