1320711e2244390b407b2c8a762365120ab056e08Matthias Clasen/* GLIB - Library of useful routines for C programming 2320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald 3320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * 4320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * This library is free software; you can redistribute it and/or 5320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * modify it under the terms of the GNU Lesser General Public 6320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * License as published by the Free Software Foundation; either 7320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * version 2 of the License, or (at your option) any later version. 8320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * 9320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * This library is distributed in the hope that it will be useful, 10320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * but WITHOUT ANY WARRANTY; without even the implied warranty of 11320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * Lesser General Public License for more details. 13320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * 14320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * You should have received a copy of the GNU Lesser General Public 15320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * License along with this library; if not, write to the 16320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * Boston, MA 02111-1307, USA. 18320711e2244390b407b2c8a762365120ab056e08Matthias Clasen */ 19320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 20320711e2244390b407b2c8a762365120ab056e08Matthias Clasen/* 21320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * Modified by the GLib Team and others 1997-2000. See the AUTHORS 22320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * file for a list of people on the GLib Team. See the ChangeLog 23320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * files for a list of changes. These files are distributed with 24320711e2244390b407b2c8a762365120ab056e08Matthias Clasen * GLib at ftp://ftp.gtk.org/pub/gtk/. 25320711e2244390b407b2c8a762365120ab056e08Matthias Clasen */ 26320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 27320711e2244390b407b2c8a762365120ab056e08Matthias Clasen#undef G_DISABLE_ASSERT 28320711e2244390b407b2c8a762365120ab056e08Matthias Clasen#undef G_LOG_DOMAIN 29320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 30320711e2244390b407b2c8a762365120ab056e08Matthias Clasen#include <string.h> 31320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 32320711e2244390b407b2c8a762365120ab056e08Matthias Clasen#include <glib.h> 33320711e2244390b407b2c8a762365120ab056e08Matthias Clasen#include <glib-object.h> 34fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen#include "gobject/gvaluecollector.h" 35320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 36320711e2244390b407b2c8a762365120ab056e08Matthias Clasenstatic void 37320711e2244390b407b2c8a762365120ab056e08Matthias Clasentest_enum_transformation (void) 38320711e2244390b407b2c8a762365120ab056e08Matthias Clasen{ 39320711e2244390b407b2c8a762365120ab056e08Matthias Clasen GType type; 40320711e2244390b407b2c8a762365120ab056e08Matthias Clasen GValue orig = { 0, }; 41320711e2244390b407b2c8a762365120ab056e08Matthias Clasen GValue xform = { 0, }; 42320711e2244390b407b2c8a762365120ab056e08Matthias Clasen GEnumValue values[] = { {0,"0","0"}, {1,"1","1"}}; 43320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 44320711e2244390b407b2c8a762365120ab056e08Matthias Clasen type = g_enum_register_static ("TestEnum", values); 45320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 46320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&orig, type); 47320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_set_enum (&orig, 1); 48320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 49320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 50320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_CHAR); 51320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 52320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_char (&xform) == 1); 53320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 54320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 55320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_UCHAR); 56320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 57320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_uchar (&xform) == 1); 58320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 59320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 60320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_INT); 61320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 62320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_int (&xform) == 1); 63320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 64320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 65320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_UINT); 66320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 67320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_uint (&xform) == 1); 68320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 69320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 70320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_LONG); 71320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 72320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_long (&xform) == 1); 73320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 74320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 75320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_ULONG); 76320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 77320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_ulong (&xform) == 1); 78320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 79320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 80320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_INT64); 81320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 82320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_int64 (&xform) == 1); 83320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 84320711e2244390b407b2c8a762365120ab056e08Matthias Clasen memset (&xform, 0, sizeof (GValue)); 85320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_init (&xform, G_TYPE_UINT64); 86320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_value_transform (&orig, &xform); 87320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_assert (g_value_get_uint64 (&xform) == 1); 88320711e2244390b407b2c8a762365120ab056e08Matthias Clasen} 89320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 90fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 91fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenstatic void 92fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasentest_gtype_value (void) 93fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen{ 94fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GType type; 95fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GValue value = { 0, }; 96fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GValue copy = { 0, }; 97fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 98fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_GTYPE); 99fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 100fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_gtype (&value, G_TYPE_BOXED); 101fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen type = g_value_get_gtype (&value); 102fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (type == G_TYPE_BOXED); 103fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 104fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (©, G_TYPE_GTYPE); 105fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_copy (&value, ©); 106fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen type = g_value_get_gtype (©); 107fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (type == G_TYPE_BOXED); 108fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen} 109fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 110fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenstatic gchar * 111fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasencollect (GValue *value, ...) 112fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen{ 113fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar *error; 114fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_list var_args; 115fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 116fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = NULL; 117fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 118fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_start (var_args, value); 119fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen G_VALUE_COLLECT (value, var_args, 0, &error); 120fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_end (var_args); 121fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 122fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen return error; 123fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen} 124fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 125fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenstatic gchar * 126fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenlcopy (GValue *value, ...) 127fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen{ 128fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar *error; 129fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_list var_args; 130fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 131fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = NULL; 132fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 133fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_start (var_args, value); 134fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen G_VALUE_LCOPY (value, var_args, 0, &error); 135fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen va_end (var_args); 136fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 137fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen return error; 138fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen} 139fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 140fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenstatic void 141fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasentest_collection (void) 142fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen{ 143fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GValue value = { 0, }; 144fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar *error; 145fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 146fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_CHAR); 147fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, 'c'); 148fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 149fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_char (&value) == 'c'); 150fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 151fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 152fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UCHAR); 153fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, 129); 154fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 155fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_uchar (&value) == 129); 156fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 157fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 158fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_BOOLEAN); 159fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, TRUE); 160fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 161fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_boolean (&value) == TRUE); 162fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 163fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 164fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_INT); 165fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXINT); 166fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 167fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_int (&value) == G_MAXINT); 168fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 169fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 170fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UINT); 171fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXUINT); 172fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 173fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_uint (&value) == G_MAXUINT); 174fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 175fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 176fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_LONG); 177fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXLONG); 178fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 179fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_long (&value) == G_MAXLONG); 180fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 181fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 182fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_ULONG); 183fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXULONG); 184fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 185fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_ulong (&value) == G_MAXULONG); 186fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 187fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 188fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_INT64); 189fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXINT64); 190fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 191fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_int64 (&value) == G_MAXINT64); 192fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 193fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 194fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UINT64); 195fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXUINT64); 196fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 197fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_uint64 (&value) == G_MAXUINT64); 198fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 199fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 200fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_FLOAT); 201fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXFLOAT); 202fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 203fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_float (&value) == G_MAXFLOAT); 204fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 205fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 206fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_DOUBLE); 207fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_MAXDOUBLE); 208fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 209fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_double (&value) == G_MAXDOUBLE); 210fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 211fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 212fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_STRING); 213fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, "string ?"); 214fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 215fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (strcmp (g_value_get_string (&value), "string ?") == 0); 216fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 217fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 218fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_GTYPE); 219fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = collect (&value, G_TYPE_BOXED); 220fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 221fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (g_value_get_gtype (&value) == G_TYPE_BOXED); 222fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen} 223fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 224fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasenstatic void 225fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasentest_copying (void) 226fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen{ 227fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GValue value = { 0, }; 228fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar *error; 229fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 230fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 231fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar c = 0; 232fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 233fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_CHAR); 234fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_char (&value, 'c'); 235fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 236fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 237fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == 'c'); 238fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 239fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 240fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 241fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen guchar c = 0; 242fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 243fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 244fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UCHAR); 245fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_uchar (&value, 129); 246fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 247fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 248fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == 129); 249fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 250fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 251fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 252fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gint c = 0; 253fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 254fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 255fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_INT); 256fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_int (&value, G_MAXINT); 257fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 258fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 259fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXINT); 260fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 261fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 262fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 263fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen guint c = 0; 264fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 265fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 266fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UINT); 267fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_uint (&value, G_MAXUINT); 268fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 269fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 270fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXUINT); 271fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 272fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 273fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 274fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen glong c = 0; 275fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 276fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 277fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_LONG); 278fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_long (&value, G_MAXLONG); 279fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 280fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 281fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXLONG); 282fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 283fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 284fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 285fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gulong c = 0; 286fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 287fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 288fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_ULONG); 289fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_ulong (&value, G_MAXULONG); 290fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 291fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 292fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXULONG); 293fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 294fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 295fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 296fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gint64 c = 0; 297fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 298fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 299fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_INT64); 300fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_int64 (&value, G_MAXINT64); 301fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 302fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 303fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXINT64); 304fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 305fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 306fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 307fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen guint64 c = 0; 308fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 309fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 310fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_UINT64); 311fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_uint64 (&value, G_MAXUINT64); 312fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 313fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 314fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXUINT64); 315fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 316fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 317fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 318fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gfloat c = 0; 319fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 320fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 321fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_FLOAT); 322fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_float (&value, G_MAXFLOAT); 323fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 324fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 325fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXFLOAT); 326fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 327fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 328fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 329fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gdouble c = 0; 330fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 331fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 332fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_DOUBLE); 333fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_double (&value, G_MAXDOUBLE); 334fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 335fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 336fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_MAXDOUBLE); 337fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 338fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 339fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 340fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen gchar *c = NULL; 341fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 342fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 343fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_STRING); 344fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_string (&value, "string ?"); 345fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 346fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 347fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (strcmp (c, "string ?") == 0); 348fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 349fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 350fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen { 351fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen GType c = G_TYPE_NONE; 352fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 353fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_unset (&value); 354fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_init (&value, G_TYPE_GTYPE); 355fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_value_set_gtype (&value, G_TYPE_BOXED); 356fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen error = lcopy (&value, &c); 357fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (error == NULL); 358fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen g_assert (c == G_TYPE_BOXED); 359fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen } 360fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen} 361fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 362fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen 363320711e2244390b407b2c8a762365120ab056e08Matthias Clasenint 364320711e2244390b407b2c8a762365120ab056e08Matthias Clasenmain (int argc, char *argv[]) 365320711e2244390b407b2c8a762365120ab056e08Matthias Clasen{ 366320711e2244390b407b2c8a762365120ab056e08Matthias Clasen g_type_init (); 367320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 368320711e2244390b407b2c8a762365120ab056e08Matthias Clasen test_enum_transformation (); 369fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen test_gtype_value (); 370fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen test_collection (); 371fb7ae4674ab5a0b93979cf3683cd52faa649c0baMatthias Clasen test_copying (); 372320711e2244390b407b2c8a762365120ab056e08Matthias Clasen 373320711e2244390b407b2c8a762365120ab056e08Matthias Clasen return 0; 374320711e2244390b407b2c8a762365120ab056e08Matthias Clasen} 375