sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* This library is free software; you can redistribute it and/or
|
sl@0
|
5 |
* modify it under the terms of the GNU Lesser General Public
|
sl@0
|
6 |
* License as published by the Free Software Foundation; either
|
sl@0
|
7 |
* version 2 of the License, or (at your option) any later version.
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* This library is distributed in the hope that it will be useful,
|
sl@0
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
sl@0
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
sl@0
|
12 |
* Lesser General Public License for more details.
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* You should have received a copy of the GNU Lesser General Public
|
sl@0
|
15 |
* License along with this library; if not, write to the
|
sl@0
|
16 |
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
sl@0
|
17 |
* Boston, MA 02111-1307, USA.
|
sl@0
|
18 |
*
|
sl@0
|
19 |
* Description: ?Description
|
sl@0
|
20 |
*
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
#undef G_DISABLE_ASSERT
|
sl@0
|
25 |
#undef G_LOG_DOMAIN
|
sl@0
|
26 |
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <stdio.h>
|
sl@0
|
29 |
#include <string.h>
|
sl@0
|
30 |
#include <glib.h>
|
sl@0
|
31 |
#include <fcntl.h>
|
sl@0
|
32 |
#include <goption.h>
|
sl@0
|
33 |
#include <glib/gprintf.h>
|
sl@0
|
34 |
|
sl@0
|
35 |
#ifdef SYMBIAN
|
sl@0
|
36 |
#include "mrt2_glib2_test.h"
|
sl@0
|
37 |
#endif /*SYMBIAN*/
|
sl@0
|
38 |
|
sl@0
|
39 |
#define C2P(c) ((gpointer) ((long) (c)))
|
sl@0
|
40 |
#define GINT_TO_POINTER(i) ((gpointer) (i))
|
sl@0
|
41 |
#define GPOINTER_TO_INT(p) ((gint) (p))
|
sl@0
|
42 |
#define TESTPASS 1
|
sl@0
|
43 |
#define TESTFAIL 0
|
sl@0
|
44 |
|
sl@0
|
45 |
//Test for g_on_error_query
|
sl@0
|
46 |
void tg_on_error_query()
|
sl@0
|
47 |
{
|
sl@0
|
48 |
printf("\nThis is a test for g_on_error_query\nChoose the foll:\n");
|
sl@0
|
49 |
g_on_error_query(NULL);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
//Test for g_printf
|
sl@0
|
53 |
void tg_printf()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
printf("This is a test for g_printf\n");
|
sl@0
|
56 |
g_printf("%d\n%s\t%f",9999999,"Abcd#%@",999.999999);
|
sl@0
|
57 |
printf("\nCase passed!..Press any key");
|
sl@0
|
58 |
getchar();
|
sl@0
|
59 |
}
|
sl@0
|
60 |
|
sl@0
|
61 |
//Support for print handler tests
|
sl@0
|
62 |
void print_func()
|
sl@0
|
63 |
{
|
sl@0
|
64 |
return;
|
sl@0
|
65 |
}
|
sl@0
|
66 |
//Print handler tests
|
sl@0
|
67 |
void tg_print_handler_test()
|
sl@0
|
68 |
{
|
sl@0
|
69 |
g_print ("%s","\nThis is a test for setting print handler\nbefore setting");
|
sl@0
|
70 |
g_set_print_handler (&print_func);
|
sl@0
|
71 |
g_print ("%s","after setting:Test Failed!");
|
sl@0
|
72 |
getchar();
|
sl@0
|
73 |
g_set_printerr_handler (&print_func);
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
//Test for g_relation_print and g_tuples_index
|
sl@0
|
77 |
void tg_relation_print()
|
sl@0
|
78 |
{
|
sl@0
|
79 |
gint i;
|
sl@0
|
80 |
GRelation *relation;
|
sl@0
|
81 |
GTuples *tuples;
|
sl@0
|
82 |
gint data [4];
|
sl@0
|
83 |
|
sl@0
|
84 |
relation = g_relation_new (2);
|
sl@0
|
85 |
|
sl@0
|
86 |
g_relation_index (relation, 0, g_int_hash, g_int_equal);
|
sl@0
|
87 |
g_relation_index (relation, 1, g_int_hash, g_int_equal);
|
sl@0
|
88 |
|
sl@0
|
89 |
for (i = 0; i < 4; i += 1)
|
sl@0
|
90 |
data[i] = i;
|
sl@0
|
91 |
|
sl@0
|
92 |
for (i = 1; i < 3; i += 1)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
g_relation_insert (relation, data + i, data + i + 1);
|
sl@0
|
95 |
g_relation_insert (relation, data + i, data + i - 1);
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
printf("This is a test case for g_relation_print.\nWhat you will see");
|
sl@0
|
99 |
printf(" is all the tuples in the relation and 2 sets of relations");
|
sl@0
|
100 |
printf("with index 0 and 1:\n");
|
sl@0
|
101 |
g_relation_print(relation);
|
sl@0
|
102 |
|
sl@0
|
103 |
tuples = g_relation_select (relation, data + 2, 0);
|
sl@0
|
104 |
g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2);
|
sl@0
|
105 |
|
sl@0
|
106 |
g_tuples_destroy(tuples);
|
sl@0
|
107 |
g_relation_destroy(relation);
|
sl@0
|
108 |
|
sl@0
|
109 |
printf("\nIn case there are no asserts then this case is passed\n");
|
sl@0
|
110 |
printf("Press any key for next test case\n");
|
sl@0
|
111 |
getchar();
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
int main (int argc,char *argv[])
|
sl@0
|
115 |
{
|
sl@0
|
116 |
|
sl@0
|
117 |
#ifdef SYMBIAN
|
sl@0
|
118 |
|
sl@0
|
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);
|
sl@0
|
120 |
#endif /*SYMBIAN*/
|
sl@0
|
121 |
|
sl@0
|
122 |
tg_relation_print();
|
sl@0
|
123 |
|
sl@0
|
124 |
|
sl@0
|
125 |
tg_printf();
|
sl@0
|
126 |
tg_print_handler_test();
|
sl@0
|
127 |
//tg_on_error_query();
|
sl@0
|
128 |
|
sl@0
|
129 |
return 0;
|
sl@0
|
130 |
} |