@@ -54,7 +54,7 @@ void testStreamString() {
5454 {
5555 // We use a a lighter StreamConstPtr(input) to make a read-only Stream out of
5656 // 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
5858 // 'result'.
5959
6060 result.clear ();
@@ -77,7 +77,7 @@ void testStreamString() {
7777 // Now inputString is made into a Stream using S2Stream,
7878 // and set in non-consume mode (using ::resetPointer()).
7979
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
8181 // until the pointer is reset.
8282
8383 S2Stream input (inputString);
@@ -87,7 +87,7 @@ void testStreamString() {
8787 input.sendAll (result);
8888 input.sendAll (result);
8989 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" );
9191 }
9292
9393 {
@@ -103,6 +103,17 @@ void testStreamString() {
103103 check (" S2Stream.resetPointer(2):" , result.c_str (), " llo" );
104104 }
105105
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+
106117 {
107118 // inputString made into a Stream
108119 // reading the Stream consumes the String
@@ -181,7 +192,8 @@ void setup() {
181192
182193 testStreamString ();
183194
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));
185197}
186198
187199#endif
0 commit comments