GNode *node_G;
GNode *node_J;
guint i;
- gchar *tstring;
+ gchar *tstring, *cstring;
g_print ("checking n-way trees: ");
failed = FALSE;
g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring);
TEST (tstring, strcmp (tstring, "ABFEDCGKJIH") == 0);
g_free (tstring); tstring = NULL;
-
+
+ cstring = NULL;
+ node = g_node_copy (root);
+ TEST (NULL, g_node_n_nodes (root, G_TRAVERSE_ALL) == g_node_n_nodes (node, G_TRAVERSE_ALL));
+ TEST (NULL, g_node_max_height (root) == g_node_max_height (node));
+ g_node_traverse (root, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &tstring);
+ g_node_traverse (node, G_IN_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &cstring);
+ TEST (cstring, strcmp (tstring, cstring) == 0);
+ g_free (tstring); tstring = NULL;
+ g_free (cstring); cstring = NULL;
+ g_node_destroy (node);
+
g_node_destroy (root);
/* allocation tests */
g_print ("and next 70:\n%s\n", string2->str+142);
g_print ("last 70 chars:\n%s\n", string2->str+string2->len - 70);
+ g_string_free (string1, TRUE);
+ g_string_free (string2, TRUE);
+
+ /* append */
+ string1 = g_string_new ("firsthalf");
+ g_string_append (string1, "lasthalf");
+ g_assert (strcmp (string1->str, "firsthalflasthalf") == 0);
+ g_string_free (string1, TRUE);
+
+ /* append_len */
+
+ string1 = g_string_new ("firsthalf");
+ g_string_append_len (string1, "lasthalfjunkjunk", strlen ("lasthalf"));
+ g_assert (strcmp (string1->str, "firsthalflasthalf") == 0);
+ g_string_free (string1, TRUE);
+
+ /* prepend */
+ string1 = g_string_new ("lasthalf");
+ g_string_prepend (string1, "firsthalf");
+ g_assert (strcmp (string1->str, "firsthalflasthalf") == 0);
+ g_string_free (string1, TRUE);
+
+ /* prepend_len */
+ string1 = g_string_new ("lasthalf");
+ g_string_prepend_len (string1, "firsthalfjunkjunk", strlen ("firsthalf"));
+ g_assert (strcmp (string1->str, "firsthalflasthalf") == 0);
+ g_string_free (string1, TRUE);
+
+ /* insert */
+ string1 = g_string_new ("firstlast");
+ g_string_insert (string1, 5, "middle");
+ g_assert (strcmp (string1->str, "firstmiddlelast") == 0);
+ g_string_free (string1, TRUE);
+
+ /* insert with pos == end of the string */
+ string1 = g_string_new ("firstmiddle");
+ g_string_insert (string1, strlen ("firstmiddle"), "last");
+ g_assert (strcmp (string1->str, "firstmiddlelast") == 0);
+ g_string_free (string1, TRUE);
+
+ /* insert_len */
+
+ string1 = g_string_new ("firstlast");
+ g_string_insert_len (string1, 5, "middlejunkjunk", strlen ("middle"));
+ g_assert (strcmp (string1->str, "firstmiddlelast") == 0);
+ g_string_free (string1, TRUE);
+
+ /* insert_len with magic -1 pos for append */
+ string1 = g_string_new ("first");
+ g_string_insert_len (string1, -1, "lastjunkjunk", strlen ("last"));
+ g_assert (strcmp (string1->str, "firstlast") == 0);
+ g_string_free (string1, TRUE);
+
+ /* insert_len with magic -1 len for strlen-the-string */
+ string1 = g_string_new ("first");
+ g_string_insert_len (string1, 5, "last", -1);
+ g_assert (strcmp (string1->str, "firstlast") == 0);
+ g_string_free (string1, TRUE);
+
g_print ("ok\n");
g_print ("checking timers...\n");
g_print ("ok\n");
#ifdef G_OS_WIN32
- g_print ("current locale: %s\n", gwin_getlocale ());
+ g_print ("current locale: %s\n", g_win32_getlocale ());
#endif
return 0;