1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/tsrc/BC/tests/gobject/gvalue-test.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,113 @@
1.4 +/* GLIB - Library of useful routines for C programming
1.5 + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
1.6 + * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
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 +
1.23 +/*
1.24 + * Modified by the GLib Team and others 1997-2000. See the AUTHORS
1.25 + * file for a list of people on the GLib Team. See the ChangeLog
1.26 + * files for a list of changes. These files are distributed with
1.27 + * GLib at ftp://ftp.gtk.org/pub/gtk/.
1.28 + */
1.29 +
1.30 +#undef G_DISABLE_ASSERT
1.31 +#undef G_LOG_DOMAIN
1.32 +
1.33 +#include <string.h>
1.34 +
1.35 +#include <glib.h>
1.36 +#include <glib-object.h>
1.37 +
1.38 +#ifdef SYMBIAN
1.39 +#include "mrt2_glib2_test.h"
1.40 +#endif /*SYMBIAN*/
1.41 +
1.42 +
1.43 +static void
1.44 +test_enum_transformation (void)
1.45 +{
1.46 + GType type;
1.47 + GValue orig = { 0, };
1.48 + GValue xform = { 0, };
1.49 + GEnumValue values[] = { {0,"0","0"}, {1,"1","1"}};
1.50 +
1.51 + type = g_enum_register_static ("TestEnum", values);
1.52 +
1.53 + g_value_init (&orig, type);
1.54 + g_value_set_enum (&orig, 1);
1.55 +
1.56 + memset (&xform, 0, sizeof (GValue));
1.57 + g_value_init (&xform, G_TYPE_CHAR);
1.58 + g_value_transform (&orig, &xform);
1.59 + g_assert (g_value_get_char (&xform) == 1);
1.60 +
1.61 + memset (&xform, 0, sizeof (GValue));
1.62 + g_value_init (&xform, G_TYPE_UCHAR);
1.63 + g_value_transform (&orig, &xform);
1.64 + g_assert (g_value_get_uchar (&xform) == 1);
1.65 +
1.66 + memset (&xform, 0, sizeof (GValue));
1.67 + g_value_init (&xform, G_TYPE_INT);
1.68 + g_value_transform (&orig, &xform);
1.69 + g_assert (g_value_get_int (&xform) == 1);
1.70 +
1.71 + memset (&xform, 0, sizeof (GValue));
1.72 + g_value_init (&xform, G_TYPE_UINT);
1.73 + g_value_transform (&orig, &xform);
1.74 + g_assert (g_value_get_uint (&xform) == 1);
1.75 +
1.76 + memset (&xform, 0, sizeof (GValue));
1.77 + g_value_init (&xform, G_TYPE_LONG);
1.78 + g_value_transform (&orig, &xform);
1.79 + g_assert (g_value_get_long (&xform) == 1);
1.80 +
1.81 + memset (&xform, 0, sizeof (GValue));
1.82 + g_value_init (&xform, G_TYPE_ULONG);
1.83 + g_value_transform (&orig, &xform);
1.84 + g_assert (g_value_get_ulong (&xform) == 1);
1.85 +
1.86 + memset (&xform, 0, sizeof (GValue));
1.87 + g_value_init (&xform, G_TYPE_INT64);
1.88 + g_value_transform (&orig, &xform);
1.89 + g_assert (g_value_get_int64 (&xform) == 1);
1.90 +
1.91 + memset (&xform, 0, sizeof (GValue));
1.92 + g_value_init (&xform, G_TYPE_UINT64);
1.93 + g_value_transform (&orig, &xform);
1.94 + g_assert (g_value_get_uint64 (&xform) == 1);
1.95 +}
1.96 +
1.97 +int
1.98 +main (int argc, char *argv[])
1.99 +{
1.100 + #ifdef SYMBIAN
1.101 +
1.102 + 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.103 + g_set_print_handler(mrtPrintHandler);
1.104 + #endif /*SYMBIAN*/
1.105 +
1.106 +
1.107 + g_type_init ();
1.108 +
1.109 + test_enum_transformation ();
1.110 +
1.111 + #if SYMBIAN
1.112 + testResultXml("gvalue-test");
1.113 + #endif /* EMULATOR */
1.114 +
1.115 + return 0;
1.116 +}