diff options
author | David Robillard <d@drobilla.net> | 2008-08-19 18:33:12 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-19 18:33:12 +0000 |
commit | 680188cc2a73f5f907215efed6a68f7f21c60ea4 (patch) | |
tree | a8c71bc831f862a8254036f5d0a15aed79e43684 /tests/queue_test.cpp | |
parent | d9d81d15397c8ad1d503777025008489a60760c9 (diff) | |
download | raul-680188cc2a73f5f907215efed6a68f7f21c60ea4.tar.gz raul-680188cc2a73f5f907215efed6a68f7f21c60ea4.tar.bz2 raul-680188cc2a73f5f907215efed6a68f7f21c60ea4.zip |
More thread-safe ringbuffer.
Add test for size/full/empty queue functions.
git-svn-id: http://svn.drobilla.net/lad/raul@1446 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'tests/queue_test.cpp')
-rw-r--r-- | tests/queue_test.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/queue_test.cpp b/tests/queue_test.cpp index 7a1d44b..1e92104 100644 --- a/tests/queue_test.cpp +++ b/tests/queue_test.cpp @@ -120,6 +120,33 @@ int main() { unsigned long total_processed = 0; + cout << "Testing size" << endl; + for (unsigned i=0; i < queue.capacity(); ++i) { + queue.push(i); + if (i == queue.capacity()-1) { + if (!queue.full()) { + cerr << "ERROR: Should be full at " << i + << " (size " << queue.capacity() << ")" << endl; + return -1; + } + } else { + if (queue.full()) { + cerr << "ERROR: Prematurely full at " << i + << " (size " << queue.capacity() << ")" << endl; + return -1; + } + } + } + + for (unsigned i=0; i < queue.capacity(); ++i) + queue.pop(); + + if (!queue.empty()) { + cerr << "ERROR: Should be empty" << endl; + return -1; + } + + cout << "Testing concurrent reading/writing" << endl; vector<WriteThread*> writers(NUM_WRITERS, new WriteThread()); struct termios orig_term; |