diff options
author | David Robillard <d@drobilla.net> | 2006-06-09 15:07:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-06-09 15:07:31 +0000 |
commit | acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad (patch) | |
tree | e31b37a2456e6d1e564c9a7146c88be259d338b0 /src/engine/tests/queue_test.cpp | |
download | ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.tar.gz ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.tar.bz2 ingen-acbda29f838280ba98cf9e9e539e9d8a6e8fc6ad.zip |
Added Om aka Graph aka god knows what
git-svn-id: http://svn.drobilla.net/lad/grauph@9 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/tests/queue_test.cpp')
-rw-r--r-- | src/engine/tests/queue_test.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/engine/tests/queue_test.cpp b/src/engine/tests/queue_test.cpp new file mode 100644 index 00000000..3381a329 --- /dev/null +++ b/src/engine/tests/queue_test.cpp @@ -0,0 +1,47 @@ +#include <iostream> +#include <string> +#include "../../common/Queue.h" + +using std::string; using std::cerr; using std::cout; using std::endl; + + +int main() +{ + Queue<int> q(10); + + cout << "New queue. Should be empty: " << q.is_empty() << endl; + cout << "Capacity: " << q.capacity() << endl; + cout << "Fill: " << q.fill() << endl; + + for (uint i=0; i < 5; ++i) { + q.push(i); + assert(!q.is_full()); + q.pop(); + } + cout << "Pushed and popped 5 elements. Queue should be empty: " << q.is_empty() << endl; + cout << "Fill: " << q.fill() << endl; + + for (uint i=10; i < 20; ++i) { + q.push(i); + } + cout << "Pushed 10 elements. Queue should be full: " << q.is_full() << endl; + cout << "Fill: " << q.fill() << endl; + + cout << "The digits 10->19 should print: " << endl; + while (!q.is_empty()) { + int foo = q.pop(); + cout << "Popped: " << foo << endl; + } + cout << "Queue should be empty: " << q.is_empty() << endl; + cout << "Fill: " << q.fill() << endl; + + cout << "Attempting to add eleven elements to queue of size 10. Only first 10 should succeed:" << endl; + for (uint i=20; i <= 39; ++i) { + cout << i; + cout << " - Fill: " << q.fill(); + cout << ", is full: " << q.is_full(); + cout << ", succeeded: " << q.push(i) << endl; + } + + return 0; +} |