os/ossrv/glib/tsrc/BC/tests/gobject/gvalue-test.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* GLIB - Library of useful routines for C programming
     2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
     3  * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     4  * This library is free software; you can redistribute it and/or
     5  * modify it under the terms of the GNU Lesser General Public
     6  * License as published by the Free Software Foundation; either
     7  * version 2 of the License, or (at your option) any later version.
     8  *
     9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    12  * Lesser General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Lesser General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 /*
    21  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
    22  * file for a list of people on the GLib Team.  See the ChangeLog
    23  * files for a list of changes.  These files are distributed with
    24  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
    25  */
    26 
    27 #undef G_DISABLE_ASSERT
    28 #undef G_LOG_DOMAIN
    29 
    30 #include <string.h>
    31 
    32 #include <glib.h>
    33 #include <glib-object.h>
    34 
    35 #ifdef SYMBIAN
    36 #include "mrt2_glib2_test.h"
    37 #endif /*SYMBIAN*/
    38 
    39 
    40 static void
    41 test_enum_transformation (void)
    42 { 
    43   GType type; 
    44   GValue orig = { 0, };
    45   GValue xform = { 0, }; 
    46   GEnumValue values[] = { {0,"0","0"}, {1,"1","1"}}; 
    47   
    48  type = g_enum_register_static ("TestEnum", values); 
    49   
    50  g_value_init (&orig, type); 
    51  g_value_set_enum (&orig, 1); 
    52 
    53  memset (&xform, 0, sizeof (GValue));
    54  g_value_init (&xform, G_TYPE_CHAR); 
    55  g_value_transform (&orig, &xform); 
    56  g_assert (g_value_get_char (&xform) == 1);
    57 
    58  memset (&xform, 0, sizeof (GValue));
    59  g_value_init (&xform, G_TYPE_UCHAR); 
    60  g_value_transform (&orig, &xform); 
    61  g_assert (g_value_get_uchar (&xform) == 1);
    62 
    63  memset (&xform, 0, sizeof (GValue));
    64  g_value_init (&xform, G_TYPE_INT); 
    65  g_value_transform (&orig, &xform); 
    66  g_assert (g_value_get_int (&xform) == 1);
    67 
    68  memset (&xform, 0, sizeof (GValue));
    69  g_value_init (&xform, G_TYPE_UINT); 
    70  g_value_transform (&orig, &xform); 
    71  g_assert (g_value_get_uint (&xform) == 1);
    72 
    73  memset (&xform, 0, sizeof (GValue));
    74  g_value_init (&xform, G_TYPE_LONG); 
    75  g_value_transform (&orig, &xform); 
    76  g_assert (g_value_get_long (&xform) == 1);
    77 
    78  memset (&xform, 0, sizeof (GValue));
    79  g_value_init (&xform, G_TYPE_ULONG); 
    80  g_value_transform (&orig, &xform); 
    81  g_assert (g_value_get_ulong (&xform) == 1);
    82 
    83  memset (&xform, 0, sizeof (GValue));
    84  g_value_init (&xform, G_TYPE_INT64); 
    85  g_value_transform (&orig, &xform); 
    86  g_assert (g_value_get_int64 (&xform) == 1);
    87 
    88  memset (&xform, 0, sizeof (GValue));
    89  g_value_init (&xform, G_TYPE_UINT64); 
    90  g_value_transform (&orig, &xform); 
    91  g_assert (g_value_get_uint64 (&xform) == 1);
    92 }
    93 
    94 int
    95 main (int argc, char *argv[])
    96 {
    97   #ifdef SYMBIAN
    98   
    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);
   100   g_set_print_handler(mrtPrintHandler);
   101   #endif /*SYMBIAN*/
   102 	  
   103 
   104   g_type_init (); 
   105   
   106   test_enum_transformation ();
   107   
   108   #if SYMBIAN
   109   testResultXml("gvalue-test");
   110   #endif /* EMULATOR */
   111 
   112   return 0;
   113 }