summaryrefslogtreecommitdiffstats
path: root/src/engine/tests/node_tree_test.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-10 01:52:02 +0000
committerDavid Robillard <d@drobilla.net>2006-06-10 01:52:02 +0000
commit98fe0e7056e6697396249531785d3899f94d79be (patch)
tree233319008d4bfb6c8bdc546bdf4a81b87ecf7f3a /src/engine/tests/node_tree_test.cpp
parent6c8eaee73b0ea66216744f49b452e22e26fe83e1 (diff)
downloadingen-98fe0e7056e6697396249531785d3899f94d79be.tar.gz
ingen-98fe0e7056e6697396249531785d3899f94d79be.tar.bz2
ingen-98fe0e7056e6697396249531785d3899f94d79be.zip
More juggling
git-svn-id: http://svn.drobilla.net/lad/grauph@15 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/tests/node_tree_test.cpp')
-rw-r--r--src/engine/tests/node_tree_test.cpp94
1 files changed, 0 insertions, 94 deletions
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;
-}