summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/tests/list_test.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-10 01:52:02 +0000
committerDavid Robillard <d@drobilla.net>2006-06-10 01:52:02 +0000
commit98fe0e7056e6697396249531785d3899f94d79be (patch)
tree233319008d4bfb6c8bdc546bdf4a81b87ecf7f3a /src/libs/engine/tests/list_test.cpp
parent6c8eaee73b0ea66216744f49b452e22e26fe83e1 (diff)
downloadingen-98fe0e7056e6697396249531785d3899f94d79be.tar.gz
ingen-98fe0e7056e6697396249531785d3899f94d79be.tar.bz2
ingen-98fe0e7056e6697396249531785d3899f94d79be.zip
More juggling
git-svn-id: http://svn.drobilla.net/lad/grauph@15 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/tests/list_test.cpp')
-rw-r--r--src/libs/engine/tests/list_test.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/libs/engine/tests/list_test.cpp b/src/libs/engine/tests/list_test.cpp
new file mode 100644
index 00000000..d2f91c9d
--- /dev/null
+++ b/src/libs/engine/tests/list_test.cpp
@@ -0,0 +1,93 @@
+#include "../List.h"
+#include <iostream>
+#include <cstddef>
+
+using std::cout; using std::endl;
+
+
+int main()
+{
+ List<int> l;
+
+ l.push_back(new ListNode<int>(1));
+ l.push_back(new ListNode<int>(2));
+ l.push_back(new ListNode<int>(3));
+ l.push_back(new ListNode<int>(4));
+ l.push_back(new ListNode<int>(5));
+ l.push_back(new ListNode<int>(6));
+ l.push_back(new ListNode<int>(7));
+ l.push_back(new ListNode<int>(8));
+
+ cout << "List:" << endl;
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ if ((*i) == 4)
+ l.remove(i);
+ }
+
+ std::cerr << "Removed 4 (by iterator)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ l.remove(1);
+
+ std::cerr << "Removed 1 (head) (by value)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ if ((*i) == 2)
+ l.remove(i);
+ }
+
+ std::cerr << "Removed 2 (head) (by iterator)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ l.remove(5);
+
+ std::cerr << "Removed 5 (by value)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ l.remove(8);
+
+ std::cerr << "Removed 8 (tail) (by value)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ if ((*i) == 7)
+ l.remove(i);
+ }
+
+ std::cerr << "Removed 7 (tail) (by iterator)...\n";
+ for (List<int>::iterator i = l.begin(); i != l.end(); ++i) {
+ cout << *i << endl;
+ }
+ cout << endl;
+
+ List<int> r;
+ r.push_back(new ListNode<int>(9));
+ r.remove(9);
+ std::cerr << "Should not see ANY numbers:\n";
+ for (List<int>::iterator i = r.begin(); i != r.end(); ++i) {
+ cout << *i << endl;
+ }
+ return 0;
+}