1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/tsrc/BC/src/tmanual.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,130 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 +*
1.7 +* This library is free software; you can redistribute it and/or
1.8 +* modify it under the terms of the GNU Lesser General Public
1.9 +* License as published by the Free Software Foundation; either
1.10 +* version 2 of the License, or (at your option) any later version.
1.11 +*
1.12 +* This library is distributed in the hope that it will be useful,
1.13 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.15 +* Lesser General Public License for more details.
1.16 +*
1.17 +* You should have received a copy of the GNU Lesser General Public
1.18 +* License along with this library; if not, write to the
1.19 +* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.20 +* Boston, MA 02111-1307, USA.
1.21 +*
1.22 +* Description: ?Description
1.23 +*
1.24 +*/
1.25 +
1.26 +
1.27 +#undef G_DISABLE_ASSERT
1.28 +#undef G_LOG_DOMAIN
1.29 +
1.30 +
1.31 +#include <stdio.h>
1.32 +#include <string.h>
1.33 +#include <glib.h>
1.34 +#include <fcntl.h>
1.35 +#include <goption.h>
1.36 +#include <glib/gprintf.h>
1.37 +
1.38 +#ifdef SYMBIAN
1.39 +#include "mrt2_glib2_test.h"
1.40 +#endif /*SYMBIAN*/
1.41 +
1.42 +#define C2P(c) ((gpointer) ((long) (c)))
1.43 +#define GINT_TO_POINTER(i) ((gpointer) (i))
1.44 +#define GPOINTER_TO_INT(p) ((gint) (p))
1.45 +#define TESTPASS 1
1.46 +#define TESTFAIL 0
1.47 +
1.48 +//Test for g_on_error_query
1.49 +void tg_on_error_query()
1.50 +{
1.51 + printf("\nThis is a test for g_on_error_query\nChoose the foll:\n");
1.52 + g_on_error_query(NULL);
1.53 +}
1.54 +
1.55 +//Test for g_printf
1.56 +void tg_printf()
1.57 +{
1.58 + printf("This is a test for g_printf\n");
1.59 + g_printf("%d\n%s\t%f",9999999,"Abcd#%@",999.999999);
1.60 + printf("\nCase passed!..Press any key");
1.61 + getchar();
1.62 +}
1.63 +
1.64 +//Support for print handler tests
1.65 +void print_func()
1.66 +{
1.67 + return;
1.68 +}
1.69 +//Print handler tests
1.70 +void tg_print_handler_test()
1.71 +{
1.72 + g_print ("%s","\nThis is a test for setting print handler\nbefore setting");
1.73 + g_set_print_handler (&print_func);
1.74 + g_print ("%s","after setting:Test Failed!");
1.75 + getchar();
1.76 + g_set_printerr_handler (&print_func);
1.77 +}
1.78 +
1.79 +//Test for g_relation_print and g_tuples_index
1.80 +void tg_relation_print()
1.81 +{
1.82 + gint i;
1.83 + GRelation *relation;
1.84 + GTuples *tuples;
1.85 + gint data [4];
1.86 +
1.87 + relation = g_relation_new (2);
1.88 +
1.89 + g_relation_index (relation, 0, g_int_hash, g_int_equal);
1.90 + g_relation_index (relation, 1, g_int_hash, g_int_equal);
1.91 +
1.92 + for (i = 0; i < 4; i += 1)
1.93 + data[i] = i;
1.94 +
1.95 + for (i = 1; i < 3; i += 1)
1.96 + {
1.97 + g_relation_insert (relation, data + i, data + i + 1);
1.98 + g_relation_insert (relation, data + i, data + i - 1);
1.99 + }
1.100 +
1.101 + printf("This is a test case for g_relation_print.\nWhat you will see");
1.102 + printf(" is all the tuples in the relation and 2 sets of relations");
1.103 + printf("with index 0 and 1:\n");
1.104 + g_relation_print(relation);
1.105 +
1.106 + tuples = g_relation_select (relation, data + 2, 0);
1.107 + g_assert(*(gint*) g_tuples_index (tuples, 0, 0) == 2);
1.108 +
1.109 + g_tuples_destroy(tuples);
1.110 + g_relation_destroy(relation);
1.111 +
1.112 + printf("\nIn case there are no asserts then this case is passed\n");
1.113 + printf("Press any key for next test case\n");
1.114 + getchar();
1.115 +}
1.116 +
1.117 +int main (int argc,char *argv[])
1.118 +{
1.119 +
1.120 + #ifdef SYMBIAN
1.121 +
1.122 + //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);
1.123 + #endif /*SYMBIAN*/
1.124 +
1.125 + tg_relation_print();
1.126 +
1.127 +
1.128 + tg_printf();
1.129 + tg_print_handler_test();
1.130 + //tg_on_error_query();
1.131 +
1.132 + return 0;
1.133 +}
1.134 \ No newline at end of file