1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/tsrc/BC/tests/dirname-test.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,138 @@
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-09 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 <stdio.h>
1.34 +#include <string.h>
1.35 +#include "glib.h"
1.36 +
1.37 +#ifdef SYMBIAN
1.38 +#include "mrt2_glib2_test.h"
1.39 +#endif /*SYMBIAN*/
1.40 +
1.41 +int array[10000];
1.42 +gboolean failed = FALSE;
1.43 +
1.44 +#define TEST(m,cond) G_STMT_START { failed = !(cond); \
1.45 +if (failed) \
1.46 + { assert_failed = TRUE;\
1.47 + if (!m) \
1.48 + g_print ("\n(%s:%d) failed for: %s\n", __FILE__, __LINE__, ( # cond )); \
1.49 + else \
1.50 + g_print ("\n(%s:%d) failed for: %s: (%s)\n", __FILE__, __LINE__, ( # cond ), (gchar*)m); \
1.51 + } \
1.52 +else \
1.53 + g_print ("."); fflush (stdout); \
1.54 +} G_STMT_END
1.55 +
1.56 +#define C2P(c) ((gpointer) ((long) (c)))
1.57 +#define P2C(p) ((gchar) ((long) (p)))
1.58 +
1.59 +#define GLIB_TEST_STRING "el dorado "
1.60 +#define GLIB_TEST_STRING_5 "el do"
1.61 +
1.62 +
1.63 +int
1.64 +main (int argc,
1.65 + char *argv[])
1.66 +{
1.67 + gint i;
1.68 + struct {
1.69 + gchar *filename;
1.70 + gchar *dirname;
1.71 + } dirname_checks[] = {
1.72 + { "/", "/" },
1.73 + { "////", "/" },
1.74 + { ".////", "." },
1.75 + { ".", "." },
1.76 + { "..", "." },
1.77 + { "../", ".." },
1.78 + { "..////", ".." },
1.79 + { "", "." },
1.80 + { "a/b", "a" },
1.81 + { "a/b/", "a/b" },
1.82 + { "c///", "c" },
1.83 + { "/a/b", "/a" },
1.84 + { "/a/b/", "/a/b" },
1.85 +#ifdef G_OS_WIN32
1.86 + { "\\", "\\" },
1.87 + { ".\\\\\\\\", "." },
1.88 + { ".\\/\\/", "." },
1.89 + { ".", "." },
1.90 + { "..", "." },
1.91 + { "..\\", ".." },
1.92 + { "..\\\\\\\\", ".." },
1.93 + { "..\\//\\", ".." },
1.94 + { "", "." },
1.95 + { "a\\b", "a" },
1.96 + { "a\\b\\", "a\\b" },
1.97 + { "\\a\\b", "\\a" },
1.98 + { "\\a\\b\\", "\\a\\b" },
1.99 + { "c\\\\\\", "c" },
1.100 + { "c/\\\\", "c" },
1.101 + { "a:", "a:." },
1.102 + { "a:foo", "a:." },
1.103 + { "a:foo\\bar", "a:foo" },
1.104 + { "a:/foo", "a:/" },
1.105 + { "a:/foo/bar", "a:/foo" },
1.106 + { "a:/", "a:/" },
1.107 + { "a://", "a:/" },
1.108 + { "a:\\foo", "a:\\" },
1.109 + { "a:\\", "a:\\" },
1.110 + { "a:\\\\", "a:\\" },
1.111 + { "a:\\/", "a:\\" },
1.112 +#endif
1.113 + };
1.114 + guint n_dirname_checks = sizeof (dirname_checks) / sizeof (dirname_checks[0]);
1.115 +
1.116 + #ifdef SYMBIAN
1.117 + 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.118 + g_set_print_handler(mrtPrintHandler);
1.119 + #endif /*SYMBIAN*/
1.120 +
1.121 +
1.122 + for (i = 0; i < n_dirname_checks; i++)
1.123 + {
1.124 + gchar *dirname;
1.125 +
1.126 + dirname = g_path_get_dirname (dirname_checks[i].filename);
1.127 + if (strcmp (dirname, dirname_checks[i].dirname) != 0)
1.128 + {
1.129 + g_assert(FALSE && "dirname-test failed");
1.130 + g_print ("%s returned %s, should return %s",dirname_checks[i].filename, dirname,dirname_checks[i].dirname);
1.131 + }
1.132 + g_free (dirname);
1.133 + }
1.134 +
1.135 + #if SYMBIAN
1.136 + testResultXml("dirname-test");
1.137 + #endif /* EMULATOR */
1.138 +
1.139 + return 0;
1.140 +}
1.141 +