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: sl@0: int main (int argc,char *argv[]) sl@0: { sl@0: sl@0: GList *list1 = NULL,*list2 = NULL,*l,*l1,*list3 = NULL; sl@0: int i; sl@0: int *value; sl@0: const char mem_allocator[] = "mem_allocator"; sl@0: GAllocator *allocator; sl@0: sl@0: int num1[] = sl@0: { sl@0: 1,2,3 sl@0: }; sl@0: sl@0: int num2[] = sl@0: { sl@0: 4,5,6 sl@0: }; sl@0: sl@0: #ifdef SYMBIAN sl@0: 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: allocator = g_allocator_new(mem_allocator,500); sl@0: sl@0: for(i=0;i<3;i++) sl@0: list1 = g_list_append (list1, &num1[i]); sl@0: sl@0: for(i=0;i<3;i++) sl@0: list2 = g_list_append (list2, &num2[i]); sl@0: sl@0: sl@0: list1 = g_list_concat(list1,list2); sl@0: sl@0: for(i=0;i<6;i++) sl@0: { sl@0: l = g_list_nth(list1,i); sl@0: g_assert(*(gint *)(l->data) == i+1); sl@0: } sl@0: sl@0: list2 = g_list_copy(list1); sl@0: sl@0: for(i=0;i<3;i++) sl@0: { sl@0: l = g_list_nth(list2,i); sl@0: g_assert(*(gint *)(l->data) == i+1); sl@0: } sl@0: sl@0: l = g_list_first(list2); sl@0: g_assert(*(gint *)(l->data) == 1); sl@0: sl@0: value = (int *)g_list_nth_data(list1,1); sl@0: sl@0: g_assert(*value == 2); sl@0: sl@0: l = g_list_nth(list1,3); sl@0: sl@0: l1 = g_list_nth_prev(l,2); sl@0: sl@0: for(i=0;i<5;i++) sl@0: { sl@0: l = g_list_nth(l1,i); sl@0: g_assert(*(gint *)(l->data) == i+2); sl@0: } sl@0: sl@0: g_list_push_allocator(allocator); sl@0: sl@0: list3 = g_list_append(list3,&num1[2]); sl@0: sl@0: g_assert(*(gint *)(list3->data) == 3); sl@0: sl@0: g_list_pop_allocator(); sl@0: sl@0: list3 = g_list_append(list3,&num1[0]); sl@0: sl@0: g_assert(*(gint *)(list3->next->data) == 1); sl@0: sl@0: list1 = g_list_append(list1,&num1[0]); sl@0: sl@0: i = g_list_length(list1); sl@0: sl@0: list1 = g_list_remove_all(list1,&num1[0]); sl@0: sl@0: i = g_list_length(list1); sl@0: sl@0: g_assert(g_list_length(list1) == 5); // should be this value as we will remove 2 1's from the list sl@0: sl@0: for(i==0;idata) != 1); sl@0: } sl@0: sl@0: g_allocator_free(allocator); sl@0: sl@0: #ifdef SYMBIAN sl@0: testResultXml("list_test"); sl@0: #endif /* EMULATOR */ sl@0: sl@0: return 0; sl@0: }