projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
implemented new working destructor for tree
[feisty_meow.git]
/
nucleus
/
library
/
tests_nodes
/
test_symbol_tree.cpp
diff --git
a/nucleus/library/tests_nodes/test_symbol_tree.cpp
b/nucleus/library/tests_nodes/test_symbol_tree.cpp
index ef9917c45d44e34cc1d0feb5e0cf4964a348c9c8..64e917e04c538861207e1bac908a670dce240ec8 100644
(file)
--- a/
nucleus/library/tests_nodes/test_symbol_tree.cpp
+++ b/
nucleus/library/tests_nodes/test_symbol_tree.cpp
@@
-28,9
+28,6
@@
#include <textual/string_manipulation.h>
#include <unit_test/unit_base.h>
#include <textual/string_manipulation.h>
#include <unit_test/unit_base.h>
-//#include <stdio.h>
-//#include <stdlib.h>
-
using namespace application;
using namespace basis;
using namespace filesystem;
using namespace application;
using namespace basis;
using namespace filesystem;
@@
-44,24
+41,28
@@
using namespace unit_test;
#define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
#define LOG(to_print) EMERGENCY_LOG(program_wide_logger().get(), astring(to_print))
-#define DEBUG_SYMBOL_TREE
+//#define DEBUG_TEST_SYMBOL_TREE
+
+// how many nodes we add to the tree.
+const int MAX_NODES_TESTED = 40000;
-class test_symbol_tree : public
virtual unit_base, virtual
public application_shell
+class test_symbol_tree : public
unit_base,
public application_shell
{
public:
{
public:
- test_symbol_tree() {}
+ test_symbol_tree()
: unit_base()
{}
DEFINE_CLASS_NAME("test_symbol_tree");
int execute();
};
int test_symbol_tree::execute()
{
DEFINE_CLASS_NAME("test_symbol_tree");
int execute();
};
int test_symbol_tree::execute()
{
-
LOG("please check memory usage and record it, then hit a key to start testing.
");
+
FUNCDEF("execute
");
try {
try {
- symbol_tree t("blork");
- symbol_tree *curr = &t;
- for (int i = 0; i < 40000; i++) {
+ // creates a crazy tree with only one branch per node, but hugely deep.
+ symbol_tree *t = new symbol_tree("blork");
+ symbol_tree *curr = t;
+ for (int i = 0; i < MAX_NODES_TESTED; i++) {
// if the current node has any branches, we'll jump on one as the next
// place.
if (curr->branches()) {
// if the current node has any branches, we'll jump on one as the next
// place.
if (curr->branches()) {
@@
-72,17
+73,27
@@
int test_symbol_tree::execute()
astring rando = string_manipulation::make_random_name(1, 10);
curr->add(new symbol_tree(rando));
}
astring rando = string_manipulation::make_random_name(1, 10);
curr->add(new symbol_tree(rando));
}
- LOG("check memory usage now with full size. then hit a key.");
+#ifdef DEBUG_TEST_SYMBOL_TREE
+ LOG("about to whack dynamic tree...");
+#endif
+ WHACK(t);
+ ASSERT_EQUAL(t, NULL_POINTER, "ensure pointer cleaned up");
+#ifdef DEBUG_TEST_SYMBOL_TREE
+ LOG("dynamic tree whacked.");
+#endif
} catch (...) {
} catch (...) {
+#ifdef DEBUG_TEST_SYMBOL_TREE
LOG("crashed during tree stuffing.");
LOG("crashed during tree stuffing.");
+#endif
return 1;
}
return 1;
}
- LOG("check memory usage after the run. then hit a key to end "
- "the program.");
+ ASSERT_TRUE(true, "testing succeeded without cleanup crashes");
+
+
-//
create a
tree structure...
-//perform known operations and validate shape of tree.
+//
hmmm: need more tests, like where we create a more balanced
tree structure...
+//
perform known operations and validate shape of tree.
return final_report();
}
return final_report();
}