From 55603c281a49070bd941e79093cc20a144f9ee4a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 15 Aug 2012 17:50:17 +0000 Subject: Rewrite Raul::Maid and eliminate Raul:List. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4702 a436a847-0d15-0410-975c-d299462d15a1 --- test/list_test.cpp | 156 ----------------------------------------------------- 1 file changed, 156 deletions(-) delete mode 100644 test/list_test.cpp (limited to 'test') diff --git a/test/list_test.cpp b/test/list_test.cpp deleted file mode 100644 index d538625..0000000 --- a/test/list_test.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - This file is part of Raul. - Copyright 2007-2012 David Robillard - - Raul is free software: you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation, either version 3 of the License, or any later version. - - Raul is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Raul. If not, see . -*/ - -#include -#include -#include "raul/log.hpp" -#include "raul/List.hpp" - -using namespace std; -using namespace Raul; - -int -main() -{ -#define CHECK(cond) \ - do { if (!(cond)) { \ - error << "Test at " << __FILE__ << ":" << __LINE__ << " failed: " << __STRING(cond) << endl; \ - return 1; \ - } } while (0) - - List l; - - l.push_back(new List::Node(1)); - l.push_back(new List::Node(2)); - l.push_back(new List::Node(3)); - l.push_back(new List::Node(4)); - l.push_back(new List::Node(5)); - l.push_back(new List::Node(6)); - l.push_back(new List::Node(7)); - l.push_back(new List::Node(8)); - - /*cout << "List:" << endl; - for (List::iterator i = l.begin(); i != l.end(); ++i) { - cout << *i << endl; - } - cout << endl;*/ - - // Remove 4 - for (List::iterator i = l.begin(); i != l.end(); ++i) { - if ((*i) == 4) { - delete l.erase(i); - break; - } - } - - // Check - int idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - if (idx < 3) - CHECK(*i == idx + 1); - else - CHECK(*i == idx + 2); - } - - // Remove 1 (head) - for (List::iterator i = l.begin(); i != l.end(); ++i) { - if ((*i) == 1) { - delete l.erase(i); - break; - } - } - - // Check - idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - if (idx < 2) - CHECK(*i == idx + 2); - else - CHECK(*i == idx + 3); - } - - // Remove 8 (tail) - for (List::iterator i = l.begin(); i != l.end(); ++i) { - if ((*i) == 8) { - delete l.erase(i); - break; - } - } - - // Check - idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - if (idx < 2) - CHECK(*i == idx + 2); - else if (idx < 4) - CHECK(*i == idx + 3); - else - CHECK(*i == 7); - } - - // Create, push, erase (should get empty list) - List r; - r.push_back(new List::Node(9)); - delete r.erase(r.begin()); - CHECK(r.size() == 0); - CHECK(r.empty()); - - // Appending to an empty list - l.clear(); - CHECK(l.size() == 0); - CHECK(l.empty()); - - List l2; - l2.push_back(new List::Node(0)); - l2.push_back(new List::Node(2)); - l2.push_back(new List::Node(4)); - l2.push_back(new List::Node(6)); - - l.append(l2); - idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - CHECK(*i == idx * 2); - } - - // Appending non-empty lists - l2.push_back(new List::Node(5)); - l2.push_back(new List::Node(6)); - l2.push_back(new List::Node(7)); - l2.push_back(new List::Node(8)); - - l.append(l2); - idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - if (idx < 4) - CHECK(*i == idx * 2); - else - CHECK(*i == idx + 1); - } - - // Appending an empty list - l2.clear(); - l.append(l2); - - idx = 0; - for (List::iterator i = l.begin(); i != l.end(); ++i, ++idx) { - if (idx < 4) - CHECK(*i == idx * 2); - else - CHECK(*i == idx + 1); - } - - return 0; -} -- cgit v1.2.1