diff options
author | David Robillard <d@drobilla.net> | 2007-10-07 17:34:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-07 17:34:19 +0000 |
commit | 91031b8f5a4bf86b39e4c4a02412a16e247f8b15 (patch) | |
tree | daa980b9768b0e9e87bedaa0cc64e1f3abfb5860 /src/libs/engine/tests | |
parent | f2d5d172ff5f0ff02e6dfe0d0bd472b068192244 (diff) | |
download | ingen-91031b8f5a4bf86b39e4c4a02412a16e247f8b15.tar.gz ingen-91031b8f5a4bf86b39e4c4a02412a16e247f8b15.tar.bz2 ingen-91031b8f5a4bf86b39e4c4a02412a16e247f8b15.zip |
Start building a common (client/server) abstract interface for graph objects.
git-svn-id: http://svn.drobilla.net/lad/ingen@834 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/tests')
-rw-r--r-- | src/libs/engine/tests/Makefile.am | 12 | ||||
-rw-r--r-- | src/libs/engine/tests/node_tree_test.cpp | 94 | ||||
-rw-r--r-- | src/libs/engine/tests/old_node_tree_test.cpp | 72 |
3 files changed, 0 insertions, 178 deletions
diff --git a/src/libs/engine/tests/Makefile.am b/src/libs/engine/tests/Makefile.am deleted file mode 100644 index bb5e8a56..00000000 --- a/src/libs/engine/tests/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -if BUILD_UNIT_TESTS - -AM_CXXFLAGS = @JACK_CFLAGS@ @LIBLO_CFLAGS@ @ALSA_CFLAGS@ @RAUL_CFLAGS@ -I../../common -common_ldadd = @JACK_LIBS@ @RAUL_LIBS@ @LIBLO_LIBS@ @ALSA_LIBS@ -lrt -node_tree_test_LDADD = $(common_ldadd) - -noinst_PROGRAMS = node_tree_test - -node_tree_test_SOURCES = \ - node_tree_test.cpp - -endif # BUILD_UNIT_TESTS diff --git a/src/libs/engine/tests/node_tree_test.cpp b/src/libs/engine/tests/node_tree_test.cpp deleted file mode 100644 index 923cb0ba..00000000 --- a/src/libs/engine/tests/node_tree_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include <cstdlib> -#include <iostream> -#include <vector> -#include "../Tree.hpp" -#include "../TreeImplementation.hpp" - -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/libs/engine/tests/old_node_tree_test.cpp b/src/libs/engine/tests/old_node_tree_test.cpp deleted file mode 100644 index 3b5ed485..00000000 --- a/src/libs/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; -} |