os/ossrv/glib/tsrc/BC/src/tmanual.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 #include <glib/gprintf.h>
    34 
    35 #ifdef SYMBIAN
    36 #include "mrt2_glib2_test.h"
    37 #endif /*SYMBIAN*/
    38 
    39 #define	C2P(c)		((gpointer) ((long) (c)))
    40 #define GINT_TO_POINTER(i)	((gpointer)  (i))
    41 #define GPOINTER_TO_INT(p)	((gint)   (p))
    42 #define TESTPASS	1
    43 #define TESTFAIL	0
    44 
    45 //Test for g_on_error_query
    46 void tg_on_error_query()
    47 {
    48 	printf("\nThis is a test for g_on_error_query\nChoose the foll:\n");
    49 	g_on_error_query(NULL);
    50 }
    51 
    52 //Test for g_printf
    53 void tg_printf()
    54 {
    55 	printf("This is a test for g_printf\n");
    56  	g_printf("%d\n%s\t%f",9999999,"Abcd#%@",999.999999);
    57  	printf("\nCase passed!..Press any key");
    58  	getchar();
    59 }
    60 
    61 //Support for print handler tests
    62 void print_func()
    63 {
    64 	return;
    65 }
    66 //Print handler tests
    67 void tg_print_handler_test()
    68 {
    69 	g_print ("%s","\nThis is a test for setting print handler\nbefore setting");
    70 	g_set_print_handler (&print_func);
    71 	g_print ("%s","after setting:Test Failed!");
    72 	getchar();
    73 	g_set_printerr_handler (&print_func);
    74 }
    75 
    76 //Test for g_relation_print and g_tuples_index
    77 void tg_relation_print()
    78 {
    79 	gint i;
    80 	GRelation *relation;
    81 	GTuples *tuples;
    82 	gint data [4];
    83 			
    84 	relation = g_relation_new (2);
    85 
    86 	g_relation_index (relation, 0, g_int_hash, g_int_equal);
    87 	g_relation_index (relation, 1, g_int_hash, g_int_equal);
    88 
    89 	for (i = 0; i < 4; i += 1)
    90 		data[i] = i;
    91 
    92 	for (i = 1; i < 3; i += 1)
    93 	{
    94 		g_relation_insert (relation, data + i, data + i + 1);
    95 		g_relation_insert (relation, data + i, data + i - 1);
    96 	}
    97 	
    98 	printf("This is a test case for g_relation_print.\nWhat you will see");
    99 	printf(" is all the tuples in the relation and 2 sets of relations");
   100 	printf("with index 0 and 1:\n");
   101 	g_relation_print(relation);
   102 	
   103 	tuples = g_relation_select (relation, data + 2, 0);
   104 	g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2);
   105 	
   106 	g_tuples_destroy(tuples);
   107 	g_relation_destroy(relation);
   108 	
   109 	printf("\nIn case there are no asserts then this case is passed\n");
   110  	printf("Press any key for next test case\n");
   111  	getchar();
   112 }
   113 
   114 int main (int argc,char *argv[])
   115 {
   116 
   117 	#ifdef SYMBIAN
   118  
   119  	//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);
   120  	#endif /*SYMBIAN*/
   121  	
   122  	tg_relation_print();
   123 
   124  
   125  	tg_printf();	
   126  	tg_print_handler_test();
   127  	//tg_on_error_query();
   128   	 
   129  	return 0;
   130 }