sl@0
|
1 |
/* GLIB - Library of useful routines for C programming
|
sl@0
|
2 |
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
sl@0
|
3 |
* Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
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 |
|
sl@0
|
20 |
/*
|
sl@0
|
21 |
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
sl@0
|
22 |
* file for a list of people on the GLib Team. See the ChangeLog
|
sl@0
|
23 |
* files for a list of changes. These files are distributed with
|
sl@0
|
24 |
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
|
sl@0
|
27 |
#undef G_DISABLE_ASSERT
|
sl@0
|
28 |
#undef G_LOG_DOMAIN
|
sl@0
|
29 |
|
sl@0
|
30 |
#include <string.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
#include <glib.h>
|
sl@0
|
33 |
#include <glib-object.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 |
|
sl@0
|
40 |
static void
|
sl@0
|
41 |
test_enum_transformation (void)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
GType type;
|
sl@0
|
44 |
GValue orig = { 0, };
|
sl@0
|
45 |
GValue xform = { 0, };
|
sl@0
|
46 |
GEnumValue values[] = { {0,"0","0"}, {1,"1","1"}};
|
sl@0
|
47 |
|
sl@0
|
48 |
type = g_enum_register_static ("TestEnum", values);
|
sl@0
|
49 |
|
sl@0
|
50 |
g_value_init (&orig, type);
|
sl@0
|
51 |
g_value_set_enum (&orig, 1);
|
sl@0
|
52 |
|
sl@0
|
53 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
54 |
g_value_init (&xform, G_TYPE_CHAR);
|
sl@0
|
55 |
g_value_transform (&orig, &xform);
|
sl@0
|
56 |
g_assert (g_value_get_char (&xform) == 1);
|
sl@0
|
57 |
|
sl@0
|
58 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
59 |
g_value_init (&xform, G_TYPE_UCHAR);
|
sl@0
|
60 |
g_value_transform (&orig, &xform);
|
sl@0
|
61 |
g_assert (g_value_get_uchar (&xform) == 1);
|
sl@0
|
62 |
|
sl@0
|
63 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
64 |
g_value_init (&xform, G_TYPE_INT);
|
sl@0
|
65 |
g_value_transform (&orig, &xform);
|
sl@0
|
66 |
g_assert (g_value_get_int (&xform) == 1);
|
sl@0
|
67 |
|
sl@0
|
68 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
69 |
g_value_init (&xform, G_TYPE_UINT);
|
sl@0
|
70 |
g_value_transform (&orig, &xform);
|
sl@0
|
71 |
g_assert (g_value_get_uint (&xform) == 1);
|
sl@0
|
72 |
|
sl@0
|
73 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
74 |
g_value_init (&xform, G_TYPE_LONG);
|
sl@0
|
75 |
g_value_transform (&orig, &xform);
|
sl@0
|
76 |
g_assert (g_value_get_long (&xform) == 1);
|
sl@0
|
77 |
|
sl@0
|
78 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
79 |
g_value_init (&xform, G_TYPE_ULONG);
|
sl@0
|
80 |
g_value_transform (&orig, &xform);
|
sl@0
|
81 |
g_assert (g_value_get_ulong (&xform) == 1);
|
sl@0
|
82 |
|
sl@0
|
83 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
84 |
g_value_init (&xform, G_TYPE_INT64);
|
sl@0
|
85 |
g_value_transform (&orig, &xform);
|
sl@0
|
86 |
g_assert (g_value_get_int64 (&xform) == 1);
|
sl@0
|
87 |
|
sl@0
|
88 |
memset (&xform, 0, sizeof (GValue));
|
sl@0
|
89 |
g_value_init (&xform, G_TYPE_UINT64);
|
sl@0
|
90 |
g_value_transform (&orig, &xform);
|
sl@0
|
91 |
g_assert (g_value_get_uint64 (&xform) == 1);
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
int
|
sl@0
|
95 |
main (int argc, char *argv[])
|
sl@0
|
96 |
{
|
sl@0
|
97 |
#ifdef SYMBIAN
|
sl@0
|
98 |
|
sl@0
|
99 |
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
|
100 |
g_set_print_handler(mrtPrintHandler);
|
sl@0
|
101 |
#endif /*SYMBIAN*/
|
sl@0
|
102 |
|
sl@0
|
103 |
|
sl@0
|
104 |
g_type_init ();
|
sl@0
|
105 |
|
sl@0
|
106 |
test_enum_transformation ();
|
sl@0
|
107 |
|
sl@0
|
108 |
#if SYMBIAN
|
sl@0
|
109 |
testResultXml("gvalue-test");
|
sl@0
|
110 |
#endif /* EMULATOR */
|
sl@0
|
111 |
|
sl@0
|
112 |
return 0;
|
sl@0
|
113 |
}
|