glib/tests/uri-test.c
changeset 18 47c74d1534e1
equal deleted inserted replaced
0:e4d67989cc36 18:47c74d1534e1
       
     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-09 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 "config.h"
       
    31 
       
    32 #include <glib.h>
       
    33 #include <stdio.h>
       
    34 #include <string.h>
       
    35 #include <stdlib.h>
       
    36 
       
    37 #ifdef __SYMBIAN32__
       
    38 #include "mrt2_glib2_test.h"
       
    39 #endif /*__SYMBIAN32__*/
       
    40 typedef struct
       
    41 {
       
    42   char *filename;
       
    43   char *hostname;
       
    44   char *expected_result;
       
    45   GConvertError expected_error; /* If failed */
       
    46 }  ToUriTest;
       
    47 
       
    48 ToUriTest
       
    49 to_uri_tests[] = {
       
    50   { "/etc", NULL, "file:///etc"},
       
    51   { "/etc", "", "file:///etc"},
       
    52   { "/etc", "otherhost", "file://otherhost/etc"},
       
    53 #if defined(G_OS_WIN32) || defined (__SYMBIAN32__)
       
    54   { "/etc", "localhost", "file:///etc"},
       
    55   { "c:\\windows", NULL, "file:///c:/windows"},
       
    56   { "c:\\windows", "localhost", "file:///c:/windows"},
       
    57   { "c:\\windows", "otherhost", "file://otherhost/c:/windows"},
       
    58   { "\\\\server\\share\\dir", NULL, "file:////server/share/dir"},
       
    59   { "\\\\server\\share\\dir", "localhost", "file:////server/share/dir"},
       
    60 #else
       
    61   { "/etc", "localhost", "file://localhost/etc"},
       
    62   { "c:\\windows", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH}, /* it's important to get this error on Unix */
       
    63   { "c:\\windows", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    64   { "c:\\windows", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    65 #endif
       
    66   { "etc", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    67 #ifndef G_PLATFORM_WIN32
       
    68   { "/etc/\xE5\xE4\xF6", NULL, "file:///etc/%E5%E4%F6" },
       
    69   { "/etc/\xC3\xB6\xC3\xA4\xC3\xA5", NULL, "file:///etc/%C3%B6%C3%A4%C3%A5"},
       
    70 #endif
       
    71   { "/etc", "\xC3\xB6\xC3\xA4\xC3\xA5", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
    72   { "/etc", "\xE5\xE4\xF6", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
    73   { "/etc/file with #%", NULL, "file:///etc/file%20with%20%23%25"},
       
    74   { "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    75   { "", "", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    76   { "", "localhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    77   { "", "otherhost", NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_PATH},
       
    78   { "/0123456789", NULL, "file:///0123456789"},
       
    79   { "/ABCDEFGHIJKLMNOPQRSTUVWXYZ", NULL, "file:///ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
       
    80   { "/abcdefghijklmnopqrstuvwxyz", NULL, "file:///abcdefghijklmnopqrstuvwxyz"},
       
    81   { "/-_.!~*'()", NULL, "file:///-_.!~*'()"},
       
    82 #if defined(G_OS_WIN32) || defined(__SYMBIAN32__)
       
    83   /* As '\\' is a path separator on Win32, it gets turned into '/' in the URI */
       
    84   { "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B/%5D%5E%60%7B%7C%7D%7F"},
       
    85 #else
       
    86   /* On Unix, '\\' is a normal character in the file name */
       
    87   { "/\"#%<>[\\]^`{|}\x7F", NULL, "file:///%22%23%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F"},
       
    88 #endif
       
    89   { "/;@+$,", NULL, "file:///%3B@+$,"},
       
    90   /* This and some of the following are of course as such illegal file names on Windows,
       
    91    * and would not occur in real life.
       
    92    */
       
    93   { "/:", NULL, "file:///:"},
       
    94   { "/?&=", NULL, "file:///%3F&="}, 
       
    95   { "/", "0123456789-", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
    96   { "/", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/"},
       
    97   { "/", "abcdefghijklmnopqrstuvwxyz", "file://abcdefghijklmnopqrstuvwxyz/"},
       
    98   { "/", "_.!~*'()", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
    99   { "/", "\"#%<>[\\]^`{|}\x7F", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   100   { "/", ";?&=+$,", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   101   { "/", "/", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   102   { "/", "@:", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   103   { "/", "\x80\xFF", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   104   { "/", "\xC3\x80\xC3\xBF", NULL, G_CONVERT_ERROR_ILLEGAL_SEQUENCE},
       
   105 };
       
   106 
       
   107 
       
   108 typedef struct
       
   109 {
       
   110   char *uri;
       
   111   char *expected_filename;
       
   112   char *expected_hostname;
       
   113   GConvertError expected_error; /* If failed */
       
   114 }  FromUriTest;
       
   115 
       
   116 FromUriTest
       
   117 from_uri_tests[] = {
       
   118   { "file:///etc", "\\etc"},
       
   119   { "file:/etc", "\\etc"},
       
   120 #if defined(G_OS_WIN32) || defined(__SYMBIAN32__)
       
   121   /* On Win32 we don't return "localhost" hostames, just in case
       
   122    * it isn't recognized anyway.
       
   123    */
       
   124   { "file://localhost/etc", "\\etc", NULL},
       
   125   /*{ "file://localhost/etc/%23%25%20file", "\\etc/#% file", NULL},*/
       
   126   { "file://localhost/\xE5\xE4\xF6", "\\\xe5\xe4\xf6", NULL},
       
   127   { "file://localhost/%E5%E4%F6", "\\\xe5\xe4\xf6", NULL},
       
   128 #else
       
   129   { "file://localhost/etc", "\etc", "localhost"},
       
   130   { "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"},
       
   131   { "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"},
       
   132   { "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"},
       
   133 #endif
       
   134   { "file://otherhost/etc", "\\etc", "otherhost"},
       
   135   /*{ "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"},*/
       
   136   { "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   137   { "file:////etc/%C3%B6%C3%C3%C3%A5", "\\\\etc\\\xc3\xb6\xc3\xc3\xc3\xa5", NULL},
       
   138   { "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   139   { "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   140   { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   141   { "file://some", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   142   { "", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   143   { "file:test", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   144   { "http://www.yahoo.com/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   145   { "file:////etc", "\\\\etc"},
       
   146   { "file://///etc", "\\\\\\etc"},
       
   147 #if defined(G_OS_WIN32) || defined (__SYMBIAN32__)
       
   148   /* URIs with backslashes come from some nonstandard application, but accept them anyhow */
       
   149   { "file:///c:\\foo", "c:\\foo"},
       
   150   { "file:///c:/foo\\bar", "c:\\foo\\bar"},
       
   151   /* Accept also the old Netscape drive-letter-and-vertical bar convention */
       
   152   { "file:///c|/foo", "c:\\foo"},
       
   153   { "file:////server/share/dir", "\\\\server\\share\\dir"},
       
   154   { "file://localhost//server/share/foo", "\\\\server\\share\\foo"},
       
   155   { "file://otherhost//server/share/foo", "\\\\server\\share\\foo", "otherhost"},
       
   156 #else
       
   157   { "file:///c:\\foo", "/c:\\foo"},
       
   158   { "file:///c:/foo", "/c:/foo"},
       
   159   { "file:////c:/foo", "//c:/foo"},
       
   160 #endif
       
   161   { "file://0123456789/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   162   { "file://ABCDEFGHIJKLMNOPQRSTUVWXYZ/", "\\", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
       
   163   { "file://abcdefghijklmnopqrstuvwxyz/", "\\", "abcdefghijklmnopqrstuvwxyz"},
       
   164   { "file://-_.!~*'()/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   165   { "file://\"<>[\\]^`{|}\x7F/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   166   { "file://;?&=+$,/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   167   { "file://%C3%80%C3%BF/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   168   { "file://@/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   169   { "file://:/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   170   { "file://#/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   171   { "file://%23/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   172   { "file://%2F/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
       
   173 };
       
   174 
       
   175 
       
   176 static gboolean any_failed = FALSE;
       
   177 
       
   178 static void
       
   179 run_to_uri_tests (void)
       
   180 {
       
   181   int i;
       
   182   gchar *res;
       
   183   GError *error;
       
   184   
       
   185   for (i = 0; i < G_N_ELEMENTS (to_uri_tests); i++)
       
   186     {
       
   187       error = NULL;
       
   188       res = g_filename_to_uri (to_uri_tests[i].filename,
       
   189 			       to_uri_tests[i].hostname,
       
   190 			       &error);
       
   191 
       
   192       if (to_uri_tests[i].expected_result == NULL)
       
   193 	{
       
   194 	  if (res != NULL)
       
   195 	    {
       
   196 	      g_print ("\ng_filename_to_uri() test %d failed, expected to return NULL, actual result: %s\n", i, res);
       
   197 	      any_failed = TRUE;
       
   198 	    }
       
   199 	  else
       
   200 	    {
       
   201 	      if (error == NULL)
       
   202 		{
       
   203 		  g_print ("\ng_filename_to_uri() test %d failed, returned NULL, but didn't set error\n", i);
       
   204 		  any_failed = TRUE;
       
   205 		}
       
   206 	      else if (error->domain != G_CONVERT_ERROR)
       
   207 		{
       
   208 		  g_print ("\ng_filename_to_uri() test %d failed, returned NULL, set non G_CONVERT_ERROR error\n", i);
       
   209 		  any_failed = TRUE;
       
   210 		}
       
   211 	      else if (error->code != to_uri_tests[i].expected_error)
       
   212 		{
       
   213 		  g_print ("\ng_filename_to_uri() test %d failed as expected, but set wrong errorcode %d instead of expected %d \n",
       
   214 			   i, error->code, to_uri_tests[i].expected_error);
       
   215 		  any_failed = TRUE;
       
   216 		}
       
   217 	    }
       
   218 	}
       
   219       else if (res == NULL || strcmp (res, to_uri_tests[i].expected_result) != 0)
       
   220 	{
       
   221 	  g_print ("\ng_filename_to_uri() test %d failed, expected result: %s, actual result: %s\n",
       
   222 		   i, to_uri_tests[i].expected_result, (res) ? res : "NULL");
       
   223 	  if (error)
       
   224 	    g_print ("Error message: %s\n", error->message);
       
   225 	  any_failed = TRUE;
       
   226 	}
       
   227       g_free (res);
       
   228     }
       
   229 }
       
   230 
       
   231 static void
       
   232 run_from_uri_tests (void)
       
   233 {
       
   234   int i;
       
   235   gchar *res;
       
   236   gchar *hostname;
       
   237   GError *error;
       
   238   
       
   239   for (i = 0; i < G_N_ELEMENTS (from_uri_tests); i++)
       
   240     {
       
   241       error = NULL;
       
   242       res = g_filename_from_uri (from_uri_tests[i].uri,
       
   243 				 &hostname,
       
   244 				 &error);
       
   245 
       
   246       if (from_uri_tests[i].expected_filename == NULL)
       
   247 	{
       
   248 	  if (res != NULL)
       
   249 	    {
       
   250 	      g_print ("\ng_filename_from_uri() test %d failed, expected to return NULL, actual result: %s\n", i, res);
       
   251 	      any_failed = TRUE;
       
   252 	    }
       
   253 	  else
       
   254 	    {
       
   255 	      if (error == NULL)
       
   256 		{
       
   257 		  g_print ("\ng_filename_from_uri() test %d failed, returned NULL, but didn't set error\n", i);
       
   258 		  any_failed = TRUE;
       
   259 		}
       
   260 	      else if (error->domain != G_CONVERT_ERROR)
       
   261 		{
       
   262 		  g_print ("\ng_filename_from_uri() test %d failed, returned NULL, set non G_CONVERT_ERROR error\n", i);
       
   263 		  any_failed = TRUE;
       
   264 		}
       
   265 	      else if (error->code != from_uri_tests[i].expected_error)
       
   266 		{
       
   267 		  g_print ("\ng_filename_from_uri() test %d failed as expected, but set wrong errorcode %d instead of expected %d \n",
       
   268 			   i, error->code, from_uri_tests[i].expected_error);
       
   269 		  any_failed = TRUE;
       
   270 		}
       
   271 	    }
       
   272 	}
       
   273       else
       
   274 	{
       
   275 #ifdef G_OS_WIN32
       
   276 	  gchar *slash, *p;
       
   277 
       
   278 	  p = from_uri_tests[i].expected_filename = g_strdup (from_uri_tests[i].expected_filename);
       
   279 	  while ((slash = strchr (p, '/')) != NULL)
       
   280 	    {
       
   281 	      *slash = '\\';
       
   282 	      p = slash + 1;
       
   283 	    }
       
   284 #endif
       
   285 	  if (res == NULL || strcmp (res, from_uri_tests[i].expected_filename) != 0)
       
   286 	    {
       
   287 	      g_print ("\ng_filename_from_uri() test %d failed, expected result: %s, actual result: %s\n",
       
   288 		       i, from_uri_tests[i].expected_filename, (res) ? res : "NULL");
       
   289 	      any_failed = TRUE;
       
   290 	    }
       
   291 
       
   292 	  if (from_uri_tests[i].expected_hostname == NULL)
       
   293 	    {
       
   294 	      if (hostname != NULL)
       
   295 		{
       
   296 		  g_print ("\ng_filename_from_uri() test %d failed, expected no hostname, got: %s\n",
       
   297 			   i, hostname);
       
   298 		  any_failed = TRUE;
       
   299 		}
       
   300 	    }
       
   301 	  else if (hostname == NULL ||
       
   302 		   strcmp (hostname, from_uri_tests[i].expected_hostname) != 0)
       
   303 	    {
       
   304 	      g_print ("\ng_filename_from_uri() test %d failed, expected hostname: %s, actual result: %s\n",
       
   305 		       i, from_uri_tests[i].expected_hostname, (hostname) ? hostname : "NULL");
       
   306 	      any_failed = TRUE;
       
   307 	    }
       
   308 	}
       
   309     }
       
   310 }
       
   311 
       
   312 static gint
       
   313 safe_strcmp (const gchar *a, const gchar *b)
       
   314 {
       
   315   return strcmp (a ? a : "", b ? b : "");
       
   316 }
       
   317 
       
   318 static gint
       
   319 safe_strcmp_filename (const gchar *a, const gchar *b)
       
   320 {
       
   321 #if !defined(G_OS_WIN32) && !defined(__SYMBIAN32__)
       
   322   return safe_strcmp (a, b);
       
   323 #else
       
   324   if (!a || !b)
       
   325     return safe_strcmp (a, b);
       
   326   else
       
   327     {
       
   328       while (*a && *b)
       
   329 	{
       
   330 	  if ((G_IS_DIR_SEPARATOR (*a) && G_IS_DIR_SEPARATOR (*b)) ||
       
   331 	      *a == *b)
       
   332 	    a++, b++;
       
   333 	  else
       
   334 	    return (*a - *b);
       
   335 	}
       
   336       return (*a - *b);
       
   337     }
       
   338 #endif
       
   339 }
       
   340 
       
   341 static gint
       
   342 safe_strcmp_hostname (const gchar *a, const gchar *b)
       
   343 {
       
   344 #if !defined(G_OS_WIN32) && !defined(__SYMBIAN32__)
       
   345   return safe_strcmp (a, b);
       
   346 #else
       
   347   if (safe_strcmp (a, "localhost") == 0 && b == NULL)
       
   348     return 0;
       
   349   else
       
   350     return safe_strcmp (a, b);
       
   351 #endif
       
   352 }
       
   353 
       
   354 static void
       
   355 run_roundtrip_tests (void)
       
   356 {
       
   357   int i;
       
   358   gchar *uri, *hostname, *res;
       
   359   GError *error;
       
   360   
       
   361   for (i = 0; i < G_N_ELEMENTS (to_uri_tests); i++)
       
   362     {
       
   363       if (to_uri_tests[i].expected_error != 0)
       
   364 	continue;
       
   365 
       
   366       error = NULL;
       
   367       uri = g_filename_to_uri (to_uri_tests[i].filename,
       
   368 			       to_uri_tests[i].hostname,
       
   369 			       &error);
       
   370       
       
   371       if (error != NULL)
       
   372 	{
       
   373 	  g_print ("g_filename_to_uri failed unexpectedly: %s\n", 
       
   374 		   error->message);
       
   375 	  any_failed = TRUE;
       
   376 	  continue;
       
   377 	}
       
   378       
       
   379       error = NULL;
       
   380       res = g_filename_from_uri (uri, &hostname, &error);
       
   381       if (error != NULL)
       
   382 	{
       
   383 	  g_print ("g_filename_from_uri failed unexpectedly: %s\n", 
       
   384 		   error->message);
       
   385 	  any_failed = TRUE;
       
   386 	  continue;
       
   387 	}
       
   388 
       
   389       if (safe_strcmp_filename (to_uri_tests[i].filename, res))
       
   390 	{
       
   391 	  g_print ("roundtrip test %d failed, filename modified: "
       
   392 		   " expected \"%s\", but got \"%s\"\n",
       
   393 		   i, to_uri_tests[i].filename, res);
       
   394 	  any_failed = TRUE;
       
   395 	}
       
   396 
       
   397       if (safe_strcmp_hostname (to_uri_tests[i].hostname, hostname))
       
   398 	{
       
   399 	  g_print ("roundtrip test %d failed, hostname modified: "
       
   400 		     " expected \"%s\", but got \"%s\"\n",
       
   401 		   i, to_uri_tests[i].hostname, hostname);
       
   402 	  any_failed = TRUE;
       
   403 	}
       
   404     }
       
   405 }
       
   406 
       
   407 static void
       
   408 run_uri_list_tests (void)
       
   409 {
       
   410   /* straight from the RFC */
       
   411   gchar *list =
       
   412     "# urn:isbn:0-201-08372-8\r\n"
       
   413     "http://www.huh.org/books/foo.html\r\n"
       
   414     "http://www.huh.org/books/foo.pdf   \r\n"
       
   415     "   ftp://ftp.foo.org/books/foo.txt\r\n";
       
   416   gchar *expected_uris[] = {
       
   417     "http://www.huh.org/books/foo.html",
       
   418     "http://www.huh.org/books/foo.pdf",
       
   419     "ftp://ftp.foo.org/books/foo.txt"
       
   420   };
       
   421 
       
   422   gchar **uris;
       
   423   gint j;
       
   424 
       
   425   uris = g_uri_list_extract_uris (list);
       
   426   
       
   427   if (g_strv_length (uris) != 3)
       
   428     {
       
   429       g_print ("uri list test failed: "
       
   430 	       " expected %d uris, but got %d\n",
       
   431 	       3, g_strv_length (uris));
       
   432       any_failed = TRUE;
       
   433     }
       
   434   
       
   435   for (j = 0; j < 3; j++)
       
   436     {
       
   437       if (safe_strcmp (uris[j], expected_uris[j])) 
       
   438 	{
       
   439 	  g_print ("uri list test failed: "
       
   440 		   " expected \"%s\", but got \"%s\"\n",
       
   441 		   expected_uris[j], uris[j]);
       
   442 	  any_failed = TRUE;
       
   443 	}
       
   444     }
       
   445 
       
   446   g_strfreev (uris);
       
   447 
       
   448   uris = g_uri_list_extract_uris ("# just hot air\r\n# more hot air");
       
   449   if (g_strv_length (uris) != 0)
       
   450     {
       
   451       g_print ("uri list test 2 failed: "
       
   452 	       " expected %d uris, but got %d (first is \"%s\")\n",
       
   453 	       0, g_strv_length (uris), uris[0]);
       
   454       any_failed = TRUE;
       
   455     }
       
   456   
       
   457 }
       
   458 
       
   459 int
       
   460 main (int   argc,
       
   461       char *argv[])
       
   462 {
       
   463   #ifdef __SYMBIAN32__
       
   464 
       
   465   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);
       
   466   g_set_print_handler(mrtPrintHandler);
       
   467   #endif /*__SYMBIAN32__*/
       
   468 #ifdef G_OS_UNIX
       
   469 #  ifdef HAVE_UNSETENV  
       
   470   unsetenv ("G_BROKEN_FILENAMES");
       
   471 #  else
       
   472   /* putenv with no = isn't standard, but works to unset the variable
       
   473    * on some systems
       
   474    */
       
   475   putenv ("G_BROKEN_FILENAMES");
       
   476 #  endif  
       
   477 #endif
       
   478 
       
   479   run_to_uri_tests ();
       
   480   run_from_uri_tests ();
       
   481   run_roundtrip_tests ();
       
   482   run_uri_list_tests ();
       
   483   #ifdef __SYMBIAN32__
       
   484   assert_failed = any_failed;
       
   485   testResultXml("uri-test");
       
   486   #endif /* EMULATOR */
       
   487 
       
   488   return any_failed ? 1 : 0;
       
   489 }