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: ?Description sl@0: * sl@0: */ sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: #define C2P(c) ((gpointer) ((long) (c))) sl@0: #define GINT_TO_POINTER(i) ((gpointer) (i)) sl@0: #define GPOINTER_TO_INT(p) ((gint) (p)) sl@0: #define TESTPASS 1 sl@0: #define TESTFAIL 0 sl@0: sl@0: //Test for g_on_error_query sl@0: void tg_on_error_query() sl@0: { sl@0: printf("\nThis is a test for g_on_error_query\nChoose the foll:\n"); sl@0: g_on_error_query(NULL); sl@0: } sl@0: sl@0: //Test for g_printf sl@0: void tg_printf() sl@0: { sl@0: printf("This is a test for g_printf\n"); sl@0: g_printf("%d\n%s\t%f",9999999,"Abcd#%@",999.999999); sl@0: printf("\nCase passed!..Press any key"); sl@0: getchar(); sl@0: } sl@0: sl@0: //Support for print handler tests sl@0: void print_func() sl@0: { sl@0: return; sl@0: } sl@0: //Print handler tests sl@0: void tg_print_handler_test() sl@0: { sl@0: g_print ("%s","\nThis is a test for setting print handler\nbefore setting"); sl@0: g_set_print_handler (&print_func); sl@0: g_print ("%s","after setting:Test Failed!"); sl@0: getchar(); sl@0: g_set_printerr_handler (&print_func); sl@0: } sl@0: sl@0: //Test for g_relation_print and g_tuples_index sl@0: void tg_relation_print() sl@0: { sl@0: gint i; sl@0: GRelation *relation; sl@0: GTuples *tuples; sl@0: gint data [4]; sl@0: sl@0: relation = g_relation_new (2); sl@0: sl@0: g_relation_index (relation, 0, g_int_hash, g_int_equal); sl@0: g_relation_index (relation, 1, g_int_hash, g_int_equal); sl@0: sl@0: for (i = 0; i < 4; i += 1) sl@0: data[i] = i; sl@0: sl@0: for (i = 1; i < 3; i += 1) sl@0: { sl@0: g_relation_insert (relation, data + i, data + i + 1); sl@0: g_relation_insert (relation, data + i, data + i - 1); sl@0: } sl@0: sl@0: printf("This is a test case for g_relation_print.\nWhat you will see"); sl@0: printf(" is all the tuples in the relation and 2 sets of relations"); sl@0: printf("with index 0 and 1:\n"); sl@0: g_relation_print(relation); sl@0: sl@0: tuples = g_relation_select (relation, data + 2, 0); sl@0: g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2); sl@0: sl@0: g_tuples_destroy(tuples); sl@0: g_relation_destroy(relation); sl@0: sl@0: printf("\nIn case there are no asserts then this case is passed\n"); sl@0: printf("Press any key for next test case\n"); sl@0: getchar(); sl@0: } sl@0: sl@0: int main (int argc,char *argv[]) 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: tg_relation_print(); sl@0: sl@0: sl@0: tg_printf(); sl@0: tg_print_handler_test(); sl@0: //tg_on_error_query(); sl@0: sl@0: return 0; sl@0: }