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.
25 #undef G_DISABLE_ASSERT
33 #include "mrt2_glib2_test.h"
36 void function(gchar *key,gchar *value,gint *user_data)
38 // give the count of the number of times the function was called
44 char *str1,*str2,*str3;
48 g_assert((cache = g_cache_new( (GCacheNewFunc) g_ascii_strup,
49 g_free, (GCacheDupFunc) g_strdup, g_free, g_str_hash,
50 g_str_hash, g_str_equal)) != NULL);
52 str1 = g_cache_insert(cache,"test");
54 g_assert(!strcmp("TEST",str1));
56 str2 = g_cache_insert(cache,"test");
58 g_assert(!strcmp("TEST",str1));
60 str3 = g_cache_insert(cache,"glib");
62 g_assert(!strcmp("GLIB",str3));
64 g_cache_key_foreach (cache,(GHFunc)function,&user_data);
66 //g_cache_key_foreach would call function twice and make user_data == 2
67 g_assert(user_data == 2);
69 g_cache_value_foreach (cache,(GHFunc)function,&user_data);
71 //g_cache_value_foreach would call function twice and make user_data == 4
72 g_assert(user_data == 4);
74 g_cache_remove(cache,str1);
75 g_cache_remove(cache,str2);
76 g_cache_remove(cache,str3);
78 g_cache_destroy(cache);
87 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);
93 testResultXml("cache_test");