summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSzilárd Pfeiffer <szilard.pfeiffer@gmail.com>2008-09-03 15:37:13 +0000
committerMurray Cumming <murrayc@src.gnome.org>2008-09-03 15:37:13 +0000
commit982c863a95f31019ca1f1397de5af54e07c7333f (patch)
tree1fe0aecb61569558ed8b0299957a90376a192a42 /tests
parent842020c03dac8fb8c66c507132c5eb512352f43c (diff)
downloadglibmm-982c863a95f31019ca1f1397de5af54e07c7333f.tar.gz
Implemented clone function to merge the constructors into that and fixed
2008-08-26 Szilárd Pfeiffer <szilard.pfeiffer@gmail.com> * glib/src/nodetree.hg: Implemented clone function to merge the constructors into that and fixed clear function the operator= function. * tests/glibmm_nodetree/main.cc: Simplified the test case. Bug #547901. svn path=/trunk/; revision=724
Diffstat (limited to 'tests')
-rw-r--r--tests/glibmm_nodetree/main.cc48
1 files changed, 18 insertions, 30 deletions
diff --git a/tests/glibmm_nodetree/main.cc b/tests/glibmm_nodetree/main.cc
index e1ca358f..74538b77 100644
--- a/tests/glibmm_nodetree/main.cc
+++ b/tests/glibmm_nodetree/main.cc
@@ -1,7 +1,7 @@
#include <iostream>
#include <glibmm.h>
-typedef Glib::NodeTree<std::string> type_nodetree_string;
+typedef Glib::NodeTree<const std::string> type_nodetree_string;
static bool node_build_string(type_nodetree_string& node, std::string& string)
{
@@ -21,41 +21,29 @@ int main()
type_nodetree_string* node_F;
type_nodetree_string* node_G;
type_nodetree_string* node_J;
- std::string str_A("A");
- std::string str_B("B");
- std::string str_C("C");
- std::string str_D("D");
- std::string str_E("E");
- std::string str_F("F");
- std::string str_G("G");
- std::string str_H("H");
- std::string str_I("I");
- std::string str_J("J");
- std::string str_K("K");
- std::string str_empty;
-
- root = new type_nodetree_string(str_A);
+
+ root = new type_nodetree_string("A");
g_assert(root->depth() == 1 && root->get_max_height() == 1);
- node_B = new type_nodetree_string(str_B);
+ node_B = new type_nodetree_string("B");
root->append(*node_B);
g_assert(root->first_child() == node_B);
- node_B->append_data(str_E);
- node_B->prepend_data(str_C);
- node_D = &node_B->insert(1, *(new type_nodetree_string(str_D)));
+ node_B->append_data("E");
+ node_B->prepend_data("C");
+ node_D = &node_B->insert(1, *(new type_nodetree_string("D")));
- node_F = new type_nodetree_string(str_F);
+ node_F = new type_nodetree_string("F");
root->append(*node_F);
g_assert(root->first_child()->next_sibling() == node_F);
- node_G = new type_nodetree_string(str_G);
+ node_G = new type_nodetree_string("G");
node_F->append(*node_G);
- node_J = new type_nodetree_string(str_J);
+ node_J = new type_nodetree_string("J");
node_G->prepend(*node_J);
- node_G->insert(42, *(new type_nodetree_string(str_K)));
- node_G->insert_data(0, str_H);
- node_G->insert(1, *(new type_nodetree_string(str_I)));
+ node_G->insert(42, *(new type_nodetree_string("K")));
+ node_G->insert_data(0, "H");
+ node_G->insert(1, *(new type_nodetree_string("I")));
g_assert(root->depth() == 1);
g_assert(root->get_max_height() == 4);
@@ -65,9 +53,9 @@ int main()
g_assert(root->node_count(type_nodetree_string::TRAVERSE_ALL) == 11);
g_assert(node_F->get_max_height() == 3);
g_assert(node_G->child_count() == 4);
- g_assert(root->find_child(str_F, type_nodetree_string::TRAVERSE_ALL) == node_F);
- g_assert(root->find(str_I, Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES) == NULL);
- g_assert(root->find(str_J, Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_LEAVES) == node_J);
+ g_assert(root->find_child("F", type_nodetree_string::TRAVERSE_ALL) == node_F);
+ g_assert(root->find("I", Glib::TRAVERSE_LEVEL_ORDER, type_nodetree_string::TRAVERSE_NON_LEAVES) == NULL);
+ g_assert(root->find("J", Glib::TRAVERSE_IN_ORDER, type_nodetree_string::TRAVERSE_LEAVES) == node_J);
for(guint i = 0; i < node_B->child_count(); i++)
{
@@ -132,12 +120,12 @@ int main()
/* allocation tests */
- root = new type_nodetree_string(str_empty);
+ root = new type_nodetree_string();
node = root;
for(guint i = 0; i < 2048; i++)
{
- node->append(*(new type_nodetree_string(str_empty)));
+ node->append(*(new type_nodetree_string()));
if((i % 5) == 4)
node = node->first_child()->next_sibling();
}