From e2f96603707c75071edaea6df940751c5e2fd261 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 9 Feb 2007 22:39:56 +0000 Subject: Moved Deletable (formerly MaidObject), List, and Array from Ingen to Raul. git-svn-id: http://svn.drobilla.net/lad/raul@294 a436a847-0d15-0410-975c-d299462d15a1 --- tests/list_test.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/list_test.cpp (limited to 'tests/list_test.cpp') diff --git a/tests/list_test.cpp b/tests/list_test.cpp new file mode 100644 index 0000000..641dc5a --- /dev/null +++ b/tests/list_test.cpp @@ -0,0 +1,94 @@ +#include +#include +#include + +using namespace std; +using namespace Raul; + + +int main() +{ + List l; + + l.push_back(new ListNode(1)); + l.push_back(new ListNode(2)); + l.push_back(new ListNode(3)); + l.push_back(new ListNode(4)); + l.push_back(new ListNode(5)); + l.push_back(new ListNode(6)); + l.push_back(new ListNode(7)); + l.push_back(new ListNode(8)); + + cout << "List:" << endl; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + cout << endl; + + + for (List::iterator i = l.begin(); i != l.end(); ++i) { + if ((*i) == 4) + l.remove(i); + } + + std::cerr << "Removed 4 (by iterator)...\n"; + for (List::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::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + cout << endl; + + for (List::iterator i = l.begin(); i != l.end(); ++i) { + if ((*i) == 2) + l.remove(i); + } + + std::cerr << "Removed 2 (head) (by iterator)...\n"; + for (List::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::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::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + cout << endl; + + for (List::iterator i = l.begin(); i != l.end(); ++i) { + if ((*i) == 7) + l.remove(i); + } + + std::cerr << "Removed 7 (tail) (by iterator)...\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + cout << endl; + + List r; + r.push_back(new ListNode(9)); + r.remove(9); + std::cerr << "Should not see ANY numbers:\n"; + for (List::iterator i = r.begin(); i != r.end(); ++i) { + cout << *i << endl; + } + return 0; +} -- cgit v1.2.1