os/ossrv/glib/tsrc/BC/tests/gobject/paramspec-test.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/glib/tsrc/BC/tests/gobject/paramspec-test.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,163 @@
     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 +#include <gobject_global.h>
    1.41 +#endif //SYMBIAN
    1.42 +
    1.43 +static void
    1.44 +test_param_spec_char (void)
    1.45 +{
    1.46 +  GParamSpec *pspec;
    1.47 +  GValue value = { 0, };
    1.48 +  gboolean modified;
    1.49 + 
    1.50 +  pspec = g_param_spec_char ("char", "nick", "blurb",
    1.51 +			     20, 40, 30, G_PARAM_READWRITE);
    1.52 +
    1.53 +  //g_param_spec_ref_force_floating(pspec);			     
    1.54 +  //g_assert(g_param_spec_is_floating(pspec)); 			     
    1.55 +  g_param_spec_ref_sink(pspec);
    1.56 +
    1.57 +  g_assert (strcmp (g_param_spec_get_name (pspec), "char") == 0);
    1.58 +  g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0);
    1.59 +  g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0);
    1.60 +
    1.61 +  g_value_init (&value, G_TYPE_CHAR);
    1.62 +  g_value_set_char (&value, 30);
    1.63 +
    1.64 +  g_assert (g_param_value_defaults (pspec, &value));
    1.65 +  
    1.66 +  g_value_set_char (&value, 0);
    1.67 +  modified = g_param_value_validate (pspec, &value);
    1.68 +  g_assert (modified && g_value_get_char (&value) == 20);
    1.69 +
    1.70 +  g_value_set_char (&value, 20);
    1.71 +  modified = g_param_value_validate (pspec, &value);
    1.72 +  g_assert (!modified && g_value_get_char (&value) == 20);
    1.73 +
    1.74 +  g_value_set_char (&value, 40);
    1.75 +  modified = g_param_value_validate (pspec, &value);
    1.76 +  g_assert (!modified && g_value_get_char (&value) == 40);
    1.77 +
    1.78 +  g_value_set_char (&value, 60);
    1.79 +  modified = g_param_value_validate (pspec, &value);
    1.80 +  g_assert (modified && g_value_get_char (&value) == 40);
    1.81 +
    1.82 +  g_param_spec_unref (pspec);
    1.83 +}
    1.84 +
    1.85 +static void
    1.86 +test_param_spec_override (void)
    1.87 +{
    1.88 +  GParamSpec *ospec, *pspec;
    1.89 +  GValue value = { 0, };
    1.90 +  gboolean modified;
    1.91 + 
    1.92 +  ospec = g_param_spec_char ("char", "nick", "blurb",
    1.93 +			     20, 40, 30, G_PARAM_READWRITE);
    1.94 +
    1.95 +  pspec = g_param_spec_override ("override", ospec);
    1.96 +
    1.97 +  g_assert (strcmp (g_param_spec_get_name (pspec), "override") == 0);
    1.98 +  g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0);
    1.99 +  g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0);
   1.100 +
   1.101 +  g_value_init (&value, G_TYPE_CHAR);
   1.102 +  g_value_set_char (&value, 30);
   1.103 +
   1.104 +  g_assert (g_param_value_defaults (pspec, &value));
   1.105 +  
   1.106 +  g_value_set_char (&value, 0);
   1.107 +  modified = g_param_value_validate (pspec, &value);
   1.108 +  g_assert (modified && g_value_get_char (&value) == 20);
   1.109 +
   1.110 +  g_value_set_char (&value, 20);
   1.111 +  modified = g_param_value_validate (pspec, &value);
   1.112 +  g_assert (!modified && g_value_get_char (&value) == 20);
   1.113 +
   1.114 +  g_value_set_char (&value, 40);
   1.115 +  modified = g_param_value_validate (pspec, &value);
   1.116 +  g_assert (!modified && g_value_get_char (&value) == 40);
   1.117 +
   1.118 +  g_value_set_char (&value, 60);
   1.119 +  modified = g_param_value_validate (pspec, &value);
   1.120 +  g_assert (modified && g_value_get_char (&value) == 40);
   1.121 +
   1.122 +  g_param_spec_unref (pspec);
   1.123 +}
   1.124 +
   1.125 +static void
   1.126 +test_param_spec_gtype (void)
   1.127 +{
   1.128 +  GParamSpec *pspec;
   1.129 +  GValue value = { 0, };
   1.130 +  gboolean modified;
   1.131 +  
   1.132 +  pspec = g_param_spec_gtype ("gtype", "nick", "blurb",
   1.133 +			      G_TYPE_PARAM, G_PARAM_READWRITE);
   1.134 +  
   1.135 +  g_value_init (&value, G_TYPE_GTYPE);
   1.136 +  g_value_set_gtype (&value, G_TYPE_PARAM);
   1.137 +
   1.138 +  g_assert (g_param_value_defaults (pspec, &value));
   1.139 +  
   1.140 +  g_value_set_gtype (&value, G_TYPE_INT);
   1.141 +  modified = g_param_value_validate (pspec, &value);
   1.142 +  g_assert (modified && g_value_get_gtype (&value) == G_TYPE_PARAM);
   1.143 +
   1.144 +  g_value_set_gtype (&value, G_TYPE_PARAM_INT);
   1.145 +  modified = g_param_value_validate (pspec, &value);
   1.146 +  g_assert (!modified && g_value_get_gtype (&value) == G_TYPE_PARAM_INT);
   1.147 +}
   1.148 +
   1.149 +int
   1.150 +main (int argc, char *argv[])
   1.151 +{
   1.152 +#ifdef SYMBIAN
   1.153 +  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.154 +  g_set_print_handler(mrtPrintHandler);
   1.155 +  #endif /*SYMBIAN*/
   1.156 +  g_type_init (); 
   1.157 +  
   1.158 +  test_param_spec_char ();
   1.159 +  test_param_spec_override ();
   1.160 +  test_param_spec_gtype ();
   1.161 +  
   1.162 +#ifdef SYMBIAN
   1.163 +testResultXml("paramspec-test");
   1.164 +#endif /*SYMBIAN*/
   1.165 +  return 0;
   1.166 +}