Skip to content

Commit da7100c

Browse files
committed
Reworking parseInt test code
1 parent 5c7276a commit da7100c

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

test/src/Stream/test_parseInt.cpp

+17-24
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@ TEST_CASE ("Testing parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = N
1818
{
1919
StreamMock mock;
2020

21-
WHEN ("Only a integer is contained in stream")
21+
WHEN ("A positive integer is contained in stream")
2222
{
2323
mock << "1234";
2424
REQUIRE(mock.parseInt() == 1234);
2525
}
26-
WHEN ("The integer is prepended by digits")
26+
WHEN ("A negative integer is contained in stream")
27+
{
28+
mock << "-1234";
29+
REQUIRE(mock.parseInt() == -1234);
30+
}
31+
WHEN ("A integer is prepended by digits")
2732
{
2833
mock << "abcdef1234";
2934
REQUIRE(mock.parseInt() == 1234);
3035
}
31-
WHEN ("The integer is prepended by whitespace chars")
36+
WHEN ("A integer is prepended by whitespace chars")
3237
{
3338
mock << "\r\n\t 1234";
3439
REQUIRE(mock.parseInt() == 1234);
@@ -39,19 +44,19 @@ TEST_CASE ("Testing parseInt(LookaheadMode lookahead = SKIP_NONE, char ignore =
3944
{
4045
StreamMock mock;
4146

42-
WHEN ("Only a integer is contained in stream")
47+
WHEN ("A positive integer is contained in stream")
4348
{
4449
mock << "1234";
4550
REQUIRE(mock.parseInt(SKIP_NONE) == 1234);
4651
REQUIRE(mock.readString() == arduino::String(""));
4752
}
48-
WHEN ("The integer is prepended by digits")
53+
WHEN ("A integer is prepended by digits")
4954
{
5055
mock << "abcdef1234";
5156
REQUIRE(mock.parseInt(SKIP_NONE) == 0);
5257
REQUIRE(mock.readString() == arduino::String("abcdef1234"));
5358
}
54-
WHEN ("The integer is prepended by whitespace chars")
59+
WHEN ("A integer is prepended by whitespace chars")
5560
{
5661
mock << "\r\n\t 1234";
5762
REQUIRE(mock.parseInt(SKIP_NONE) == 0);
@@ -63,19 +68,7 @@ TEST_CASE ("Testing parseInt(LookaheadMode lookahead = SKIP_WHITESPACE, char ign
6368
{
6469
StreamMock mock;
6570

66-
WHEN ("Only a integer is contained in stream")
67-
{
68-
mock << "1234";
69-
REQUIRE(mock.parseInt(SKIP_WHITESPACE) == 1234);
70-
REQUIRE(mock.readString() == arduino::String(""));
71-
}
72-
WHEN ("The integer is prepended by digits")
73-
{
74-
mock << "abcdef1234";
75-
REQUIRE(mock.parseInt(SKIP_WHITESPACE) == 0);
76-
REQUIRE(mock.readString() == arduino::String("abcdef1234"));
77-
}
78-
WHEN ("The integer is prepended by whitespace chars")
71+
WHEN ("A integer is prepended by whitespace chars")
7972
{
8073
mock << "\r\n\t 1234";
8174
REQUIRE(mock.parseInt(SKIP_WHITESPACE) == 1234);
@@ -87,22 +80,22 @@ TEST_CASE ("Testing parseInt(LookaheadMode lookahead = SKIP_ALL, char ignore = '
8780
{
8881
StreamMock mock;
8982

90-
WHEN ("Only a integer is contained in stream")
83+
WHEN ("A positive integer is contained in stream")
9184
{
9285
mock << "1234";
9386
REQUIRE(mock.parseInt(SKIP_ALL, 'a') == 1234);
9487
REQUIRE(mock.readString() == arduino::String(""));
9588
}
96-
WHEN ("The integer contains only ignore char values")
89+
WHEN ("A integer contains only ignore char values")
9790
{
9891
mock << "12a3a4a";
99-
REQUIRE(mock.parseInt(SKIP_NONE, 'a') == 1234);
92+
REQUIRE(mock.parseInt(SKIP_ALL, 'a') == 1234);
10093
REQUIRE(mock.readString() == arduino::String(""));
10194
}
102-
WHEN ("The integer contains other than ignore chars")
95+
WHEN ("A integer contains other than ignore chars")
10396
{
10497
mock << "1bed234";
105-
REQUIRE(mock.parseInt(SKIP_NONE, 'a') == 1);
98+
REQUIRE(mock.parseInt(SKIP_ALL, 'a') == 1);
10699
REQUIRE(mock.readString() == arduino::String("bed234"));
107100
}
108101
}

0 commit comments

Comments
 (0)