diff options
author | David Robillard <d@drobilla.net> | 2007-02-09 22:39:56 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-02-09 22:39:56 +0000 |
commit | e2f96603707c75071edaea6df940751c5e2fd261 (patch) | |
tree | ebccd3ffa3a8a9f07fd465dbdd5a0b8b537c08b4 /tests | |
parent | 6ba53b4851df28e68f68f68129bf7d869dfb2b67 (diff) | |
download | raul-e2f96603707c75071edaea6df940751c5e2fd261.tar.gz raul-e2f96603707c75071edaea6df940751c5e2fd261.tar.bz2 raul-e2f96603707c75071edaea6df940751c5e2fd261.zip |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/list_test.cpp | 94 |
2 files changed, 97 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 9fba352..9ae9810 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,16 +3,18 @@ if BUILD_TESTS AM_CXXFLAGS = -I.. -lpthread @RASQAL_CFLAGS@ @GLIBMM_CFLAGS@ ALL_LIBS = @RASQAL_LIBS@ @GLIBMM_LIBS@ ../src/libraul.la -bin_PROGRAMS = path_test thread_test queue_test atomic_test +bin_PROGRAMS = path_test thread_test queue_test atomic_test list_test thread_test_LDADD = $(ALL_LIBS) path_test_LDADD = $(ALL_LIBS) queue_test_LDADD = $(ALL_LIBS) atomic_test_LDADD = $(ALL_LIBS) +list_test_LDADD = $(ALL_LIBS) path_test_SOURCES = path_test.cpp thread_test_SOURCES = thread_test.cpp queue_test_SOURCES = queue_test.cpp atomic_test_SOURCES = atomic_test.cpp +list_test_SOURCES = list_test.cpp endif 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 <iostream> +#include <cstddef> +#include <raul/List.h> + +using namespace std; +using namespace Raul; + + +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; +} |