First public contribution.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
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.
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.
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.
19 * Description: ?Description
24 #undef G_DISABLE_ASSERT
33 #include <glib/gprintf.h>
36 #include "mrt2_glib2_test.h"
39 #define C2P(c) ((gpointer) ((long) (c)))
40 #define GINT_TO_POINTER(i) ((gpointer) (i))
41 #define GPOINTER_TO_INT(p) ((gint) (p))
45 //Test for g_on_error_query
46 void tg_on_error_query()
48 printf("\nThis is a test for g_on_error_query\nChoose the foll:\n");
49 g_on_error_query(NULL);
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");
61 //Support for print handler tests
67 void tg_print_handler_test()
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!");
73 g_set_printerr_handler (&print_func);
76 //Test for g_relation_print and g_tuples_index
77 void tg_relation_print()
84 relation = g_relation_new (2);
86 g_relation_index (relation, 0, g_int_hash, g_int_equal);
87 g_relation_index (relation, 1, g_int_hash, g_int_equal);
89 for (i = 0; i < 4; i += 1)
92 for (i = 1; i < 3; i += 1)
94 g_relation_insert (relation, data + i, data + i + 1);
95 g_relation_insert (relation, data + i, data + i - 1);
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);
103 tuples = g_relation_select (relation, data + 2, 0);
104 g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2);
106 g_tuples_destroy(tuples);
107 g_relation_destroy(relation);
109 printf("\nIn case there are no asserts then this case is passed\n");
110 printf("Press any key for next test case\n");
114 int main (int argc,char *argv[])
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);
126 tg_print_handler_test();
127 //tg_on_error_query();