6 // Mock the serial port using a string stream class
7 // This will allow us to assert what gets sent on the serial port
8 class StringStream
: public Stream
11 StringStream(std::string
&s
) : buf(s
), position(0) { }
14 int available() { return buf
.length() - position
; }
15 int read() { return position
< buf
.length() ? buf
[position
++] : -1; }
16 int peek() { return position
< buf
.length() ? buf
[position
] : -1; }
20 size_t write(uint8_t c
)
22 buf
+= (char)c
; return 1;
24 size_t write(uint8_t *c
, int l
)
26 for (int i
=0; i
<l
; buf
+= *c
, i
++, c
++);
33 unsigned int position
;