glib/tsrc/BC/src/tmanual.c
changeset 0 e4d67989cc36
child 18 47c74d1534e1
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 *
       
     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.
       
     8 *
       
     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.
       
    13 *
       
    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.
       
    18 *
       
    19 * Description:  ?Description
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 #undef G_DISABLE_ASSERT
       
    25 #undef G_LOG_DOMAIN
       
    26 
       
    27 
       
    28 #include <stdio.h>
       
    29 #include <string.h>
       
    30 #include <glib.h>
       
    31 #include <fcntl.h>
       
    32 #include <goption.h>
       
    33 
       
    34 #ifdef SYMBIAN
       
    35 #include "mrt2_glib2_test.h"
       
    36 #endif /*SYMBIAN*/
       
    37 
       
    38 #define	C2P(c)		((gpointer) ((long) (c)))
       
    39 #define GINT_TO_POINTER(i)	((gpointer)  (i))
       
    40 #define GPOINTER_TO_INT(p)	((gint)   (p))
       
    41 #define TESTPASS	1
       
    42 #define TESTFAIL	0
       
    43 
       
    44 //Test for g_on_error_query
       
    45 void tg_on_error_query()
       
    46 {
       
    47 	printf("\nThis is a test for g_on_error_query\nChoose the foll:\n");
       
    48 	g_on_error_query(NULL);
       
    49 }
       
    50 
       
    51 //Test for g_printf
       
    52 void tg_printf()
       
    53 {
       
    54 	printf("This is a test for g_printf\n");
       
    55  	g_printf("%d\n%s\t%f",9999999,"Abcd#%@",999.999999);
       
    56  	printf("\nCase passed!..Press any key");
       
    57  	getchar();
       
    58 }
       
    59 
       
    60 //Support for print handler tests
       
    61 void print_func()
       
    62 {
       
    63 	return;
       
    64 }
       
    65 //Print handler tests
       
    66 void tg_print_handler_test()
       
    67 {
       
    68 	g_print ("%s","\nThis is a test for setting print handler\nbefore setting");
       
    69 	g_set_print_handler (&print_func);
       
    70 	g_print ("%s","after setting:Test Failed!");
       
    71 	getchar();
       
    72 	g_set_printerr_handler (&print_func);
       
    73 }
       
    74 
       
    75 //Test for g_relation_print and g_tuples_index
       
    76 void tg_relation_print()
       
    77 {
       
    78 	gint i;
       
    79 	GRelation *relation;
       
    80 	GTuples *tuples;
       
    81 	gint data [4];
       
    82 			
       
    83 	relation = g_relation_new (2);
       
    84 
       
    85 	g_relation_index (relation, 0, g_int_hash, g_int_equal);
       
    86 	g_relation_index (relation, 1, g_int_hash, g_int_equal);
       
    87 
       
    88 	for (i = 0; i < 4; i += 1)
       
    89 		data[i] = i;
       
    90 
       
    91 	for (i = 1; i < 3; i += 1)
       
    92 	{
       
    93 		g_relation_insert (relation, data + i, data + i + 1);
       
    94 		g_relation_insert (relation, data + i, data + i - 1);
       
    95 	}
       
    96 	
       
    97 	printf("This is a test case for g_relation_print.\nWhat you will see");
       
    98 	printf(" is all the tuples in the relation and 2 sets of relations");
       
    99 	printf("with index 0 and 1:\n");
       
   100 	g_relation_print(relation);
       
   101 	
       
   102 	tuples = g_relation_select (relation, data + 2, 0);
       
   103 	g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2);
       
   104 	
       
   105 	g_tuples_destroy(tuples);
       
   106 	g_relation_destroy(relation);
       
   107 	
       
   108 	printf("\nIn case there are no asserts then this case is passed\n");
       
   109  	printf("Press any key for next test case\n");
       
   110  	getchar();
       
   111 }
       
   112 
       
   113 int main (int argc,char *argv[])
       
   114 {
       
   115 
       
   116 	#ifdef SYMBIAN
       
   117  
       
   118  	//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  	#endif /*SYMBIAN*/
       
   120  	
       
   121  	tg_relation_print();
       
   122 
       
   123  
       
   124  	tg_printf();	
       
   125  	tg_print_handler_test();
       
   126  	//tg_on_error_query();
       
   127   	 
       
   128  	return 0;
       
   129 }