diff options
Diffstat (limited to 'src/engine/tests')
-rw-r--r-- | src/engine/tests/Makefile.am | 27 | ||||
-rw-r--r-- | src/engine/tests/list_test.cpp | 93 | ||||
-rw-r--r-- | src/engine/tests/node_tree_test.cpp | 94 | ||||
-rw-r--r-- | src/engine/tests/old_node_tree_test.cpp | 72 | ||||
-rw-r--r-- | src/engine/tests/queue_test.cpp | 47 |
5 files changed, 0 insertions, 333 deletions
diff --git a/src/engine/tests/Makefile.am b/src/engine/tests/Makefile.am deleted file mode 100644 index 54f6ad1f..00000000 --- a/src/engine/tests/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -if BUILD_UNIT_TESTS - -AM_CXXFLAGS = @JACK_CFLAGS@ @LOSC_CFLAGS@ @ALSA_CFLAGS@ -I../../common -common_ldadd = @JACK_LIBS@ @LOSC_LIBS@ @ALSA_LIBS@ -lrt -node_tree_test_LDADD = $(common_ldadd) -queue_test_LDADD = $(common_ldadd) - -bin_PROGRAMS = node_tree_test queue_test list_test path_test - -list_test_SOURCES = \ - ../List.h \ - list_test.cpp - -path_test_SOURCES = \ - ../../common/Path.h \ - path_test.cpp - -node_tree_test_SOURCES = \ - node_tree_test.cpp \ - ../Tree.h \ - ../TreeImplementation.h - -queue_test_SOURCES = \ - queue_test.cpp \ - ../../common/Queue.h - -endif # BUILD_UNIT_TESTS diff --git a/src/engine/tests/list_test.cpp b/src/engine/tests/list_test.cpp deleted file mode 100644 index d2f91c9d..00000000 --- a/src/engine/tests/list_test.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#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; -} diff --git a/src/engine/tests/node_tree_test.cpp b/src/engine/tests/node_tree_test.cpp deleted file mode 100644 index 2bce9b97..00000000 --- a/src/engine/tests/node_tree_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include <cstdlib> -#include <iostream> -#include <vector> -#include "../Tree.h" -#include "../TreeImplementation.h" - -using std::vector; -using std::cout; using std::cerr; using std::endl; - -static const uint NUM_NODES = 20; - -int -main() -{ - cout << "\n\n\n\n"; - - Tree<string> tree; - vector<string> names; - vector<bool> in_tree; // arrays - uint num_in_tree = 0; - - - string name; - - for (uint i=0; i < NUM_NODES; ++i) { - name = (char)(i+'A'); - TreeNode<string>* n = new TreeNode<string>(name, name); - tree.insert(n); - names.push_back(name); - in_tree.push_back(true); - ++num_in_tree; - } - - cout << "Added " << NUM_NODES << " nodes." << endl; - cout << "Tree size: " << tree.size() << endl << endl; - - cout << "Tree contents: " << endl; - for (Tree<string>::iterator i = tree.begin(); i != tree.end(); ++i) { - cout << (*i) << ", "; - } - cout << endl; - - - while (true) { - bool insert; - int num = rand() % NUM_NODES; - - if (num_in_tree == 0) - insert = true; - else if (num_in_tree == NUM_NODES) - insert = false; - else { - while (true) { - insert = rand() % 2; - num = rand() % NUM_NODES; - if ((insert && !in_tree[num]) || (!insert && in_tree[num])) - break; - } - } - - string name = names[num]; - - if (insert) { - assert(in_tree[num] == false); - cout << "\nInserting '" << name << "'" << endl; - tree.insert(new TreeNode<string>(name, name)); - in_tree[num] = true; - ++num_in_tree; - cout << "Tree size: " << tree.size() << endl; - assert(num_in_tree == tree.size()); - } else { - assert(in_tree[num] == true); - cout << "\nRemoving '" << name << "'" << endl; - TreeNode<string>* removed = tree.remove(name); - assert(removed != NULL); - assert(removed->node() == name); - assert(removed->key() == name); - delete removed; - in_tree[num] = false; - assert(names[num] == name); - --num_in_tree; - cout << "Tree size: " << tree.size() << endl; - assert(num_in_tree == tree.size()); - } - assert(num_in_tree == tree.size()); - cout << "Tree contents: " << endl; - for (Tree<string>::iterator i = tree.begin(); i != tree.end(); ++i) { - cout << (*i) << ", "; - } - cout << endl; - } - - return 0; -} diff --git a/src/engine/tests/old_node_tree_test.cpp b/src/engine/tests/old_node_tree_test.cpp deleted file mode 100644 index 3b5ed485..00000000 --- a/src/engine/tests/old_node_tree_test.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include <iostream> -#include "../NodeTree.h" -#include "../NodeBase.h" - -using std::cout; using std::cerr; using std::endl; - -int main() -{ - cout << "\n\n\n\n"; - - NodeBase* n = NULL; - TreeNode* tn = NULL; - TreeNode* baz = NULL; - TreeNode* quuux = NULL; - TreeNode* bar = NULL; - - NodeTree tree; - n = new NodeBase("foo", 0, 0, 0); - tn = new TreeNode(n); - tree.insert(tn); - n = new NodeBase("bar", 0, 0, 0); - bar = new TreeNode(n); - tree.insert(bar); - n = new NodeBase("baz", 0, 0, 0); - baz = new TreeNode(n); - tree.insert(baz); - n = new NodeBase("quux", 0, 0, 0); - tn = new TreeNode(n); - tree.insert(tn); - n = new NodeBase("quuux", 0, 0, 0); - quuux = new TreeNode(n); - tree.insert(quuux); - n = new NodeBase("quuuux", 0, 0, 0); - tn = new TreeNode(n); - tree.insert(tn); - - - cout << "Added 6 nodes." << endl; - cout << "Tree size: " << tree.size() << endl << endl; - - cout << "Iterating: " << endl; - for (NodeTree::iterator i = tree.begin(); i != tree.end(); ++i) { - cout << (*i)->name() << endl; - } - - cout << endl << "Search 'foo' - " << tree.find("foo")->name() << endl; - cout << endl << "Search 'bar' - " << tree.find("bar")->name() << endl; - cout << endl << "Search 'baz' - " << tree.find("baz")->name() << endl; - cout << endl << "Search 'quux' - " << tree.find("quux")->name() << endl; - cout << endl << "Search 'quuux' - " << tree.find("quuux")->name() << endl; - cout << endl << "Search 'quuuux' - " << tree.find("quuuux")->name() << endl; - cout << endl << "Search 'dave' - " << tree.find("dave") << endl; - cout << endl << "Search 'fo' - " << tree.find("fo") << endl << endl; - - cout << "Removing 'baz'." << endl; - tree.remove(baz); - - cout << "Iterating: " << endl; - for (NodeTree::iterator i = tree.begin(); i != tree.end(); ++i) { - cout << (*i)->name() << endl; - } - - cout << "Removing 'bar' (the root): " << endl; - tree.remove(bar); - - cout << "Iterating: " << endl; - for (NodeTree::iterator i = tree.begin(); i != tree.end(); ++i) { - cout << (*i)->name() << endl; - } - - return 0; -} diff --git a/src/engine/tests/queue_test.cpp b/src/engine/tests/queue_test.cpp deleted file mode 100644 index 3381a329..00000000 --- a/src/engine/tests/queue_test.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include <iostream> -#include <string> -#include "../../common/Queue.h" - -using std::string; using std::cerr; using std::cout; using std::endl; - - -int main() -{ - Queue<int> q(10); - - cout << "New queue. Should be empty: " << q.is_empty() << endl; - cout << "Capacity: " << q.capacity() << endl; - cout << "Fill: " << q.fill() << endl; - - for (uint i=0; i < 5; ++i) { - q.push(i); - assert(!q.is_full()); - q.pop(); - } - cout << "Pushed and popped 5 elements. Queue should be empty: " << q.is_empty() << endl; - cout << "Fill: " << q.fill() << endl; - - for (uint i=10; i < 20; ++i) { - q.push(i); - } - cout << "Pushed 10 elements. Queue should be full: " << q.is_full() << endl; - cout << "Fill: " << q.fill() << endl; - - cout << "The digits 10->19 should print: " << endl; - while (!q.is_empty()) { - int foo = q.pop(); - cout << "Popped: " << foo << endl; - } - cout << "Queue should be empty: " << q.is_empty() << endl; - cout << "Fill: " << q.fill() << endl; - - cout << "Attempting to add eleven elements to queue of size 10. Only first 10 should succeed:" << endl; - for (uint i=20; i <= 39; ++i) { - cout << i; - cout << " - Fill: " << q.fill(); - cout << ", is full: " << q.is_full(); - cout << ", succeeded: " << q.push(i) << endl; - } - - return 0; -} |