diff options
author | David Robillard <d@drobilla.net> | 2010-01-07 21:27:39 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-07 21:27:39 +0000 |
commit | 0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95 (patch) | |
tree | 4d41dea009f1647519af8df10f114cd7a6165792 /test/ringbuffer_test.cpp | |
parent | 61ac4a41f0aea63f45d7b27be3ef2e0554e93ece (diff) | |
download | raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.tar.gz raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.tar.bz2 raul-0d009a4e980e40dc8a9c9b5e3d25c3fafb363e95.zip |
Move unit testing and coverage framework into autowaf.
Make raul tests return 0 on success, 1 on failure.
Test coverage for Raul.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2368 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/ringbuffer_test.cpp')
-rw-r--r-- | test/ringbuffer_test.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/ringbuffer_test.cpp b/test/ringbuffer_test.cpp new file mode 100644 index 0000000..87b81c6 --- /dev/null +++ b/test/ringbuffer_test.cpp @@ -0,0 +1,47 @@ +#include <iostream> +#include <cstring> +#include "raul/RingBuffer.hpp" + +using namespace std; +using namespace Raul; + +void +print_buf(size_t size, char* buf) +{ + cout << "{ "; + for (size_t i=0; i < size; ++i) { + cout << buf[i]; + if (i < size-1) + cout << ", "; + } + + cout << " }" << endl; +} + + +int +main() +{ + RingBuffer<char> rb(5); + + char ev[] = { 'a', 'b', 'c' }; + + rb.write(3, ev); + + char buf[3]; + rb.read(3, buf); + print_buf(3, buf); + + char ev2[] = { 'd', 'e', 'f' }; + rb.write(3, ev2); + + + size_t read = rb.read(3, buf); + if (read < 3) + rb.read(3 - read, buf + read); + + print_buf(3, buf); + + return 0; +} + |