sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: #include sl@0: #include sl@0: #include "glib.h" sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: struct data sl@0: { sl@0: char a[50],b[50],c[50]; sl@0: }; sl@0: sl@0: void function(GQuark key_id,gpointer data,gpointer user_data) sl@0: { sl@0: int *i = (int *)user_data; sl@0: (*i)++; sl@0: } sl@0: sl@0: void dataset_test() sl@0: { sl@0: struct data *d = g_malloc(sizeof(struct data)); sl@0: gchar *str1,*str2,*str3,*str4,*str5,*str6; sl@0: int user_data = 0; sl@0: sl@0: GQuark q1,q2,q3; sl@0: sl@0: strcpy(d->a,"test1"); sl@0: strcpy(d->b,"test2"); sl@0: strcpy(d->c,"test3"); sl@0: sl@0: q1 = g_quark_from_string(d->a); sl@0: q2 = g_quark_from_string(d->b); sl@0: q3 = g_quark_from_string(d->c); sl@0: sl@0: g_dataset_id_set_data_full(d,q1,d->a,NULL); sl@0: g_dataset_id_set_data_full(d,q2,d->b,NULL); sl@0: g_dataset_id_set_data_full(d,q3,d->c,NULL); sl@0: sl@0: str1 = g_dataset_id_get_data(d,q1); sl@0: str2 = g_dataset_id_get_data(d,q2); sl@0: str3 = g_dataset_id_get_data(d,q3); sl@0: sl@0: // These assertions will check whether g_dataset_id_set_data_full & sl@0: // g_dataset_id_get_data is sucessful or not sl@0: g_assert(!strcmp(str1,d->a)); sl@0: g_assert(!strcmp(str2,d->b)); sl@0: g_assert(!strcmp(str3,d->c)); sl@0: sl@0: str4 = g_dataset_id_remove_no_notify(d,q1); sl@0: str5 = g_dataset_id_get_data(d,q1); sl@0: sl@0: //This assertion will check if g_dataset_id_remove_no_notify is sucessful or not sl@0: g_assert(!strcmp(str4,d->a)); sl@0: g_assert(str5 == NULL); sl@0: sl@0: g_dataset_foreach(d,function,&user_data); sl@0: sl@0: sl@0: //This assertion will check if g_dataset_foreach is sucessful or not sl@0: g_assert(user_data == 2); sl@0: sl@0: g_dataset_destroy(d); sl@0: sl@0: str6 = g_dataset_id_get_data(d,q2); sl@0: sl@0: //This assertion will check if g_dataset_destroy is successful or not sl@0: g_assert(str5 == NULL); sl@0: sl@0: } sl@0: sl@0: sl@0: int main (int argc, sl@0: char *argv[]) sl@0: { sl@0: #ifdef SYMBIAN sl@0: 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); sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: dataset_test(); sl@0: sl@0: #if SYMBIAN sl@0: testResultXml("dataset_test"); sl@0: #endif /* EMULATOR */ sl@0: sl@0: return 0; sl@0: }