Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Description: ?Description
24 #undef G_DISABLE_ASSERT
35 #include "mrt2_glib2_test.h"
38 #define C2P(c) ((gpointer) ((long) (c)))
39 #define GINT_TO_POINTER(i) ((gpointer) (i))
40 #define GPOINTER_TO_INT(p) ((gint) (p))
45 static gint my_compare (gconstpointer a,gconstpointer b,gpointer data)
53 static gint my_traverse (gpointer key,gpointer value,gpointer data)
57 g_assert (key == value);
75 tree = g_tree_new_with_data (my_compare,&c);
77 for (j = 0; j < 26; j++, i++)
80 g_tree_insert (tree, &chars[i], &chars[i]);
83 for (j = 0; j < 26; j++, i++)
86 g_tree_insert (tree, &chars[i], &chars[i]);
89 //Test for g_tree_lookup...srch for value for 'a'
90 g_assert(*(gchar*)( g_tree_lookup (tree ,&c)) == 'a');
91 g_assert(g_tree_lookup (tree ,&err) == NULL);
93 //Test for g_tree_lookup_extended...srch for value for 'a'
94 g_assert( g_tree_lookup_extended(tree ,&c ,&d ,&op));
95 g_assert( !g_tree_lookup_extended(tree ,&err ,&d ,&op));
97 //Test for g_tree_replace...replace f/f with f/z
98 g_tree_replace(tree,&key,&val);
99 g_assert(*(gchar*)( g_tree_lookup (tree ,&key)) == 'z');
101 //Test for g_tree_steal...remove f/z
102 g_assert(g_tree_steal(tree ,&key));
104 //Test for g_tree_traverse...logging occurs in the traversal function
105 g_tree_traverse(tree,my_traverse,G_IN_ORDER,&del);
109 int main (int argc,char *argv[])
114 g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL);
119 testResultXml("ttree");
120 #endif /* EMULATOR */