Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CircularBuffer TestSupportLite mbed
Revision 1:0b6bc5c2c913, committed 2014-01-30
- Comitter:
- johnb
- Date:
- Thu Jan 30 20:26:17 2014 +0000
- Parent:
- 0:6383f958c806
- Commit message:
- Add a couple of tests for [] operator
Changed in this revision
CircularBuffer.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6383f958c806 -r 0b6bc5c2c913 CircularBuffer.lib --- a/CircularBuffer.lib Sun Jan 19 17:18:55 2014 +0000 +++ b/CircularBuffer.lib Thu Jan 30 20:26:17 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/johnb/code/CircularBuffer/#e2d532183250 +http://mbed.org/users/johnb/code/CircularBuffer/#d318a6948091
diff -r 6383f958c806 -r 0b6bc5c2c913 main.cpp --- a/main.cpp Sun Jan 19 17:18:55 2014 +0000 +++ b/main.cpp Thu Jan 30 20:26:17 2014 +0000 @@ -19,15 +19,20 @@ TST_EQ( buffer.getCapacity(), TEST_BUFFER_SIZE, "Empty buffer: capacity()" ); } +#define FIRST_TEST_BYTE 0x55U + int main() { check_empty(); - temp_buffer[ 0 ] = 0x55; + temp_buffer[ 0 ] = FIRST_TEST_BYTE; /* Write a single byte into the buffer then call various methods */ TST_EQ( buffer.write( temp_buffer, 1 ), 1, "Empty buffer: write() single byte" ); + TST_EQ( buffer[0], FIRST_TEST_BYTE, "Single byte buffer: [] operator to read first byte" ); TST_EQ( buffer.getSize(), 1, "Single-byte buffer: getSize()" ); + temp_buffer[0]++; TST_EQ( buffer.peek( temp_buffer, TEST_BUFFER_SIZE ), 1, "Single-byte buffer: peek()" ); + TST_EQ( temp_buffer[0], FIRST_TEST_BYTE, "Single-byte buffer: peek() yielded correct value" ); TST_FALSE( buffer.isEmpty(), "Single-byte buffer: isEmpty()" ); TST_FALSE( buffer.isFull(), "Single-byte buffer: isFull()" ); TST_EQ( buffer.getCapacity(), TEST_BUFFER_SIZE, "Single-byte buffer: capacity()" );