@@ -54,7 +54,7 @@ void testStreamString() {
54
54
{
55
55
// We use a a lighter StreamConstPtr(input) to make a read-only Stream out of
56
56
// a String that obviously should not be modified during the time the
57
- // StreamConstPtr instance is used. It is used as a source to be sent to
57
+ // StreamConstPtr instance is used. It is used as a read-only source to be sent to
58
58
// 'result'.
59
59
60
60
result.clear ();
@@ -77,7 +77,7 @@ void testStreamString() {
77
77
// Now inputString is made into a Stream using S2Stream,
78
78
// and set in non-consume mode (using ::resetPointer()).
79
79
80
- // Then, after that input is read once, it won't be anymore readable
80
+ // Then, after input is read once, it won't be anymore readable
81
81
// until the pointer is reset.
82
82
83
83
S2Stream input (inputString);
@@ -87,7 +87,7 @@ void testStreamString() {
87
87
input.sendAll (result);
88
88
input.sendAll (result);
89
89
check (" S2Stream.sendAll(StreamString)" , result.c_str (), " hello" );
90
- check (" unmodified String given to S2Stream" , inputString.c_str (), " hello" );
90
+ check (" String given to S2Stream is unmodified " , inputString.c_str (), " hello" );
91
91
}
92
92
93
93
{
@@ -103,6 +103,17 @@ void testStreamString() {
103
103
check (" S2Stream.resetPointer(2):" , result.c_str (), " llo" );
104
104
}
105
105
106
+ {
107
+ // Streaming to a regular String
108
+
109
+ String someSource{ F (" hello" ) };
110
+ String someDestString;
111
+
112
+ StreamConstPtr (someSource).sendAll (S2Stream (someDestString));
113
+ StreamConstPtr (someSource).sendAll (S2Stream (someDestString));
114
+ check (" StreamConstPtr(someSource).sendAll(S2Stream(someDestString))" , someDestString.c_str (), " hellohello" );
115
+ }
116
+
106
117
{
107
118
// inputString made into a Stream
108
119
// reading the Stream consumes the String
@@ -181,7 +192,8 @@ void setup() {
181
192
182
193
testStreamString ();
183
194
184
- Serial.printf (" sizeof: String:%d Stream:%d StreamString:%d SStream:%d\n " , (int )sizeof (String), (int )sizeof (Stream), (int )sizeof (StreamString), (int )sizeof (S2Stream));
195
+ Serial.printf (" sizeof: String:%zu Stream:%zu StreamString:%zu S2Stream:%zu StreamConstPtr:%zu\n " ,
196
+ sizeof (String), sizeof (Stream), sizeof (StreamString), sizeof (S2Stream), sizeof (StreamConstPtr));
185
197
}
186
198
187
199
#endif
0 commit comments