Skip to content

Commit e67d2e9

Browse files
author
James Foster
committed
Stream::readStreamUntil() should not return delimiter.
1 parent 84d7ad4 commit e67d2e9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

SampleProjects/TestSomething/test/stream.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,16 @@ unittest(stream_parse)
6969

7070
}
7171

72+
unittest(readStringUntil) {
73+
String data = "";
74+
unsigned long micros = 100;
75+
data = "abc:def";
76+
77+
Stream s;
78+
s.mGodmodeDataIn = &data;
79+
s.mGodmodeMicrosDelay = &micros;
80+
// result should not include delimiter
81+
assertEqual("abc", s.readStringUntil(':'));
82+
assertEqual("def", s.readStringUntil(':'));
83+
}
7284
unittest_main()

cpp/arduino/Stream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Stream : public Print
186186
ret = String(*mGodmodeDataIn);
187187
mGodmodeDataIn->clear();
188188
} else {
189-
ret = mGodmodeDataIn->substring(0, idxTrm + 1);
189+
ret = mGodmodeDataIn->substring(0, idxTrm);
190190
fastforward(idxTrm + 1);
191191
}
192192
return ret;

0 commit comments

Comments
 (0)