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/node_tree_test.cpp | |
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/node_tree_test.cpp')
-rw-r--r-- | src/libs/engine/tests/node_tree_test.cpp | 94 |
1 files changed, 0 insertions, 94 deletions
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; -} |