sl@0: /* GLIB - Library of useful routines for C programming sl@0: * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald sl@0: * Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: */ sl@0: sl@0: /* sl@0: * Modified by the GLib Team and others 1997-2000. See the AUTHORS sl@0: * file for a list of people on the GLib Team. See the ChangeLog sl@0: * files for a list of changes. These files are distributed with sl@0: * GLib at ftp://ftp.gtk.org/pub/gtk/. sl@0: */ sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: #include sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #include sl@0: #endif //SYMBIAN sl@0: sl@0: static void sl@0: test_param_spec_char (void) sl@0: { sl@0: GParamSpec *pspec; sl@0: GValue value = { 0, }; sl@0: gboolean modified; sl@0: sl@0: pspec = g_param_spec_char ("char", "nick", "blurb", sl@0: 20, 40, 30, G_PARAM_READWRITE); sl@0: sl@0: //g_param_spec_ref_force_floating(pspec); sl@0: //g_assert(g_param_spec_is_floating(pspec)); sl@0: g_param_spec_ref_sink(pspec); sl@0: sl@0: g_assert (strcmp (g_param_spec_get_name (pspec), "char") == 0); sl@0: g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0); sl@0: g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0); sl@0: sl@0: g_value_init (&value, G_TYPE_CHAR); sl@0: g_value_set_char (&value, 30); sl@0: sl@0: g_assert (g_param_value_defaults (pspec, &value)); sl@0: sl@0: g_value_set_char (&value, 0); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (modified && g_value_get_char (&value) == 20); sl@0: sl@0: g_value_set_char (&value, 20); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (!modified && g_value_get_char (&value) == 20); sl@0: sl@0: g_value_set_char (&value, 40); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (!modified && g_value_get_char (&value) == 40); sl@0: sl@0: g_value_set_char (&value, 60); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (modified && g_value_get_char (&value) == 40); sl@0: sl@0: g_param_spec_unref (pspec); sl@0: } sl@0: sl@0: static void sl@0: test_param_spec_override (void) sl@0: { sl@0: GParamSpec *ospec, *pspec; sl@0: GValue value = { 0, }; sl@0: gboolean modified; sl@0: sl@0: ospec = g_param_spec_char ("char", "nick", "blurb", sl@0: 20, 40, 30, G_PARAM_READWRITE); sl@0: sl@0: pspec = g_param_spec_override ("override", ospec); sl@0: sl@0: g_assert (strcmp (g_param_spec_get_name (pspec), "override") == 0); sl@0: g_assert (strcmp (g_param_spec_get_nick (pspec), "nick") == 0); sl@0: g_assert (strcmp (g_param_spec_get_blurb (pspec), "blurb") == 0); sl@0: sl@0: g_value_init (&value, G_TYPE_CHAR); sl@0: g_value_set_char (&value, 30); sl@0: sl@0: g_assert (g_param_value_defaults (pspec, &value)); sl@0: sl@0: g_value_set_char (&value, 0); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (modified && g_value_get_char (&value) == 20); sl@0: sl@0: g_value_set_char (&value, 20); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (!modified && g_value_get_char (&value) == 20); sl@0: sl@0: g_value_set_char (&value, 40); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (!modified && g_value_get_char (&value) == 40); sl@0: sl@0: g_value_set_char (&value, 60); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (modified && g_value_get_char (&value) == 40); sl@0: sl@0: g_param_spec_unref (pspec); sl@0: } sl@0: sl@0: static void sl@0: test_param_spec_gtype (void) sl@0: { sl@0: GParamSpec *pspec; sl@0: GValue value = { 0, }; sl@0: gboolean modified; sl@0: sl@0: pspec = g_param_spec_gtype ("gtype", "nick", "blurb", sl@0: G_TYPE_PARAM, G_PARAM_READWRITE); sl@0: sl@0: g_value_init (&value, G_TYPE_GTYPE); sl@0: g_value_set_gtype (&value, G_TYPE_PARAM); sl@0: sl@0: g_assert (g_param_value_defaults (pspec, &value)); sl@0: sl@0: g_value_set_gtype (&value, G_TYPE_INT); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (modified && g_value_get_gtype (&value) == G_TYPE_PARAM); sl@0: sl@0: g_value_set_gtype (&value, G_TYPE_PARAM_INT); sl@0: modified = g_param_value_validate (pspec, &value); sl@0: g_assert (!modified && g_value_get_gtype (&value) == G_TYPE_PARAM_INT); sl@0: } sl@0: sl@0: int sl@0: main (int argc, char *argv[]) sl@0: { sl@0: #ifdef SYMBIAN sl@0: 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: g_set_print_handler(mrtPrintHandler); sl@0: #endif /*SYMBIAN*/ sl@0: g_type_init (); sl@0: sl@0: test_param_spec_char (); sl@0: test_param_spec_override (); sl@0: test_param_spec_gtype (); sl@0: sl@0: #ifdef SYMBIAN sl@0: testResultXml("paramspec-test"); sl@0: #endif /*SYMBIAN*/ sl@0: return 0; sl@0: }