glib/tsrc/glib_nonstif/src/completion_test.c
branchRCL_3
changeset 57 2efc27d87e1c
parent 0 e4d67989cc36
equal deleted inserted replaced
56:acd3cd4aaceb 57:2efc27d87e1c
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #undef G_DISABLE_ASSERT
       
    22 #undef G_LOG_DOMAIN
       
    23 
       
    24 #include <stdio.h>
       
    25 #include <glib.h>
       
    26 #include <string.h>
       
    27 
       
    28 #ifdef __SYMBIAN32__
       
    29 #include "mrt2_glib2_test.h"
       
    30 #endif /*__SYMBIAN32__*/
       
    31 
       
    32 int main (int argc, char *argv[])
       
    33 {
       
    34 	GCompletion *cmp;
       
    35 	GList *items;
       
    36 	gchar *prefix;
       
    37 
       
    38 	#ifdef __SYMBIAN32__
       
    39 	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);
       
    40 	#endif 
       
    41 
       
    42 	cmp = g_completion_new (NULL);
       
    43 
       
    44 	items = NULL;
       
    45 	items = g_list_append (items, "Abcdef");
       
    46 	items = g_list_append (items, "AbcDEF");
       
    47 	items = g_list_append (items, "bc");
       
    48 	items = g_list_append (items, "bd");
       
    49 			
       
    50 	g_completion_add_items (cmp, items);
       
    51 	
       
    52 	g_completion_set_compare(cmp,strncasecmp);
       
    53 	
       
    54 	items = g_completion_complete (cmp, "aB", &prefix);
       
    55 	g_assert (!strcmp ("aBc", prefix));
       
    56 	g_free (prefix);
       
    57 		
       
    58 	g_completion_remove_items(cmp,items);
       
    59 	
       
    60 	items = g_completion_complete (cmp, "aB", &prefix);
       
    61 	g_assert(items == NULL);
       
    62 	
       
    63 	items = g_completion_complete (cmp, "b", &prefix);
       
    64 	g_assert(!strcmp("b",prefix));
       
    65 	g_free(prefix);
       
    66 	
       
    67 	g_completion_clear_items(cmp);
       
    68 	
       
    69 	items = g_completion_complete (cmp, "b", &prefix);
       
    70 	g_assert(items == NULL);
       
    71 	
       
    72 	#if __SYMBIAN32__
       
    73   	testResultXml("completion_test");
       
    74   	#endif /* EMULATOR */	
       
    75 
       
    76 	return 0;
       
    77 }