AUnit
1.7.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
|
An implementation of Print that writes to an in-memory buffer. More...
#include <FakePrint.h>
Public Member Functions | |
size_t | write (uint8_t c) override |
size_t | write (const uint8_t *buffer, size_t size) override |
void | flush () override |
const char * | getBuffer () const |
Return the NUL terminated string buffer. More... | |
Static Public Attributes | |
static const uint8_t | kBufSize = 8 * sizeof(long long) + 2 + 1 |
Size of the internal buffer. More... | |
An implementation of Print that writes to an in-memory buffer.
The buffer can be retrieved using getBuffer() to verify that the expected string was written to the Print object.
Usage:
* { * FakePrint fakePrint; * object.printTo(fakePrint); * assertEqual("expected", fakePrint.getBuffer()); * fakePrint.flush(); * ... * } *
The internal buffer size is just big enough to hold a long long
(8 bytes) with 3 bytes to hold the \\r\\n
from a println()
statement and the terminating NUL character.
This class is an early version of the PrintStr class of the AceCommon library. We don't want to change AUnit to use PrintStr instead because we use AUnit to write the unit tests for AceCommon itself, and it would cause a conceptual cyclic dependency. Also we want AUnit to be self-contained without additional dependencies.
Definition at line 60 of file FakePrint.h.
|
inline |
Return the NUL terminated string buffer.
After the buffer is no longer needed, the flush() method should be called to reset the internal buffer index to 0.
Definition at line 104 of file FakePrint.h.
|
static |
Size of the internal buffer.
This is just large enough to hold the string representation of one 64-bit integer in binary format (64 bytes), including 2 bytes for the '\r\n' from println() and 1 byte for the terminating NUL.
Definition at line 68 of file FakePrint.h.