From a23b21908e4d0fab277a9f6f7d5a3b5a69746740 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 2 Apr 2007 00:26:21 +0000 Subject: List appending. Make SMFReader abort gracefully on non-SMF files. git-svn-id: http://svn.drobilla.net/lad/raul@389 a436a847-0d15-0410-975c-d299462d15a1 --- tests/list_test.cpp | 81 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 7 deletions(-) (limited to 'tests/list_test.cpp') diff --git a/tests/list_test.cpp b/tests/list_test.cpp index faee491..133067b 100644 --- a/tests/list_test.cpp +++ b/tests/list_test.cpp @@ -33,7 +33,7 @@ int main() } } - std::cerr << "Removed 4 (by iterator)...\n"; + cout << "Removed 4 (by iterator)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -41,7 +41,7 @@ int main() /*l.remove(1); - std::cerr << "Removed 1 (head) (by value)...\n"; + cout << "Removed 1 (head) (by value)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -55,7 +55,7 @@ int main() } } - std::cerr << "Removed 2 (head) (by iterator)...\n"; + cout << "Removed 2 (head) (by iterator)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -63,7 +63,7 @@ int main() /*l.remove(5); - std::cerr << "Removed 5 (by value)...\n"; + cout << "Removed 5 (by value)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -71,7 +71,7 @@ int main() l.remove(8); - std::cerr << "Removed 8 (tail) (by value)...\n"; + cout << "Removed 8 (tail) (by value)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -84,7 +84,7 @@ int main() } } - std::cerr << "Removed 7 (tail) (by iterator)...\n"; + cout << "Removed 7 (tail) (by iterator)...\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } @@ -93,9 +93,76 @@ int main() List r; r.push_back(new ListNode(9)); r.erase(r.begin()); - std::cerr << "Should not see ANY numbers:\n"; + cout << "Should not see ANY numbers:\n"; for (List::iterator i = r.begin(); i != r.end(); ++i) { cout << *i << endl; } + + cout << "\n\nTesting appending to an empty list:\n"; + l.clear(); + + List l2; + l2.push_back(new ListNode(1)); + l2.push_back(new ListNode(2)); + l2.push_back(new ListNode(3)); + l2.push_back(new ListNode(4)); + + cout << "l1:\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + + cout << "l2:\n"; + for (List::iterator i = l2.begin(); i != l2.end(); ++i) { + cout << *i << endl; + } + + l.append(l2); + cout << "l1.append(l2):\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + + cout << "\n\nAppending non-empty lists:\n"; + l2.push_back(new ListNode(5)); + l2.push_back(new ListNode(6)); + l2.push_back(new ListNode(7)); + l2.push_back(new ListNode(8)); + + cout << "l1:\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + + cout << "l2:\n"; + for (List::iterator i = l2.begin(); i != l2.end(); ++i) { + cout << *i << endl; + } + + l.append(l2); + cout << "l1.append(l2):\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + + + cout << "\n\nAppending an empty list:\n"; + + cout << "l1:\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + + cout << "l2:\n"; + for (List::iterator i = l2.begin(); i != l2.end(); ++i) { + cout << *i << endl; + } + + l.append(l2); + cout << "l1.append(l2):\n"; + for (List::iterator i = l.begin(); i != l.end(); ++i) { + cout << *i << endl; + } + return 0; } -- cgit v1.2.1