ArduinoUnit 2.0
 All Classes Files Functions Variables Macros
Public Member Functions | List of all members
FakeStream Class Reference

#include <FakeStream.h>

Inheritance diagram for FakeStream:

Public Member Functions

 FakeStream ()
 
virtual ~FakeStream ()
 
size_t write (uint8_t val)
 
void flush ()
 
const String & bytesWritten ()
 
void setToEndOfStream ()
 
void nextByte (byte b)
 
int available ()
 
int read ()
 
int peek ()
 

Detailed Description

A fake stream which can be used in place of other streams to inject bytes to be read and to record any bytes written.

Author
Matthew Murdoch

Constructor & Destructor Documentation

FakeStream::FakeStream ( )

Creates a fake stream. Until nextByte() is called all bytes returned from read() or peek() will be -1 (end-of-stream).

FakeStream::~FakeStream ( )
virtual

Destroys this fake stream.

Member Function Documentation

int FakeStream::available ( )

The number of bytes available to be read.

Returns
the number of available bytes (always 1)
const String & FakeStream::bytesWritten ( )

The bytes written by calling write(uint8_t).

Returns
the bytes written
void FakeStream::flush ( )

Flushes this stream. Does nothing in this implementation.

void FakeStream::nextByte ( byte  b)

Sets the value of the next byte to be read via read() or peek().

Parameters
bthe byte value
int FakeStream::peek ( )

Reads a byte without removing it from the stream.

Returns
the byte passed to nextByte() or -1 (end-of-stream) if nextByte() has not been called or setToEndOfStream() has been called
int FakeStream::read ( )

Reads a byte, removing it from the stream.

Returns
the byte passed to nextByte() or -1 (end-of-stream) if nextByte() has not been called or setToEndOfStream() has been called
void FakeStream::setToEndOfStream ( )

Sets the next value to be read via read() or peek() to -1 (end-of-stream).

size_t FakeStream::write ( uint8_t  val)

Writes a byte to this stream. The byte is recorded by appending it to the internal store and can be observed by calling bytesWritten().

Parameters
valthe byte to write
Returns
the number of bytes written (always 1)

The documentation for this class was generated from the following files: