Make it pass on Win32. (from_uri_tests[]): Take into consideration that on

2005-08-01  Tor Lillqvist  <tml@novell.com>

	* tests/uri-test.c: Make it pass on Win32.
	(from_uri_tests[]): Take into consideration that on Win32 we don't
	return "localhost" hostnames.
	(safe_strcmp_filename): New function that considers slash and
	backslash equal on Win32.
	(run_roundtrip_tests): Use safe_strcmp_filename().
This commit is contained in:
Tor Lillqvist 2005-08-01 19:17:35 +00:00 committed by Tor Lillqvist
parent 2d1cf6c139
commit d5a989875b
5 changed files with 65 additions and 3 deletions

View File

@ -1,3 +1,12 @@
2005-08-01 Tor Lillqvist <tml@novell.com>
* tests/uri-test.c: Make it pass on Win32.
(from_uri_tests[]): Take into consideration that on Win32 we don't
return "localhost" hostnames.
(safe_strcmp_filename): New function that considers slash and
backslash equal on Win32.
(run_roundtrip_tests): Use safe_strcmp_filename().
Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org> Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: * glib/gdataset.c:

View File

@ -1,3 +1,12 @@
2005-08-01 Tor Lillqvist <tml@novell.com>
* tests/uri-test.c: Make it pass on Win32.
(from_uri_tests[]): Take into consideration that on Win32 we don't
return "localhost" hostnames.
(safe_strcmp_filename): New function that considers slash and
backslash equal on Win32.
(run_roundtrip_tests): Use safe_strcmp_filename().
Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org> Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: * glib/gdataset.c:

View File

@ -1,3 +1,12 @@
2005-08-01 Tor Lillqvist <tml@novell.com>
* tests/uri-test.c: Make it pass on Win32.
(from_uri_tests[]): Take into consideration that on Win32 we don't
return "localhost" hostnames.
(safe_strcmp_filename): New function that considers slash and
backslash equal on Win32.
(run_roundtrip_tests): Use safe_strcmp_filename().
Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org> Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: * glib/gdataset.c:

View File

@ -1,3 +1,12 @@
2005-08-01 Tor Lillqvist <tml@novell.com>
* tests/uri-test.c: Make it pass on Win32.
(from_uri_tests[]): Take into consideration that on Win32 we don't
return "localhost" hostnames.
(safe_strcmp_filename): New function that considers slash and
backslash equal on Win32.
(run_roundtrip_tests): Use safe_strcmp_filename().
Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org> Sun Jul 31 01:50:20 2005 Tim Janik <timj@gtk.org>
* glib/gdataset.c: * glib/gdataset.c:

View File

@ -120,17 +120,19 @@ from_uri_tests[] = {
*/ */
{ "file://localhost/etc", "/etc", NULL}, { "file://localhost/etc", "/etc", NULL},
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", NULL}, { "file://localhost/etc/%23%25%20file", "/etc/#% file", NULL},
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", NULL},
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", NULL},
#else #else
{ "file://localhost/etc", "/etc", "localhost"}, { "file://localhost/etc", "/etc", "localhost"},
{ "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"}, { "file://localhost/etc/%23%25%20file", "/etc/#% file", "localhost"},
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"},
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"},
#endif #endif
{ "file://otherhost/etc", "/etc", "otherhost"}, { "file://otherhost/etc", "/etc", "otherhost"},
{ "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"}, { "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"},
{ "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file://%C3%B6%C3%A4%C3%A5/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
{ "file:////etc/%C3%B6%C3%C3%C3%A5", "//etc/\xc3\xb6\xc3\xc3\xc3\xa5", NULL}, { "file:////etc/%C3%B6%C3%C3%C3%A5", "//etc/\xc3\xb6\xc3\xc3\xc3\xa5", NULL},
{ "file://localhost/\xE5\xE4\xF6", "/\xe5\xe4\xf6", "localhost"},
{ "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file://\xE5\xE4\xF6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
{ "file://localhost/%E5%E4%F6", "/\xe5\xe4\xf6", "localhost"},
{ "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file://%E5%E4%F6/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
{ "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
{ "file://some", NULL, NULL, G_CONVERT_ERROR_BAD_URI}, { "file://some", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
@ -309,6 +311,30 @@ safe_strcmp (const gchar *a, const gchar *b)
return strcmp (a ? a : "", b ? b : ""); return strcmp (a ? a : "", b ? b : "");
} }
static gint
safe_strcmp_filename (const gchar *a, const gchar *b)
{
#ifdef G_OS_WIN32
return safe_strcmp (a, b);
#else
if (!a)
return safe_strcmp ("", b);
else if (!b)
return safe_strcmp (a, "");
else
{
while (*a && *b)
{
if ((G_IS_DIR_SEPARATOR (*a) && G_IS_DIR_SEPARATOR (*b)) ||
*a == *b)
a++, b++;
else
return (*a - *b);
}
}
#endif
}
static void static void
run_roundtrip_tests (void) run_roundtrip_tests (void)
{ {
@ -344,7 +370,7 @@ run_roundtrip_tests (void)
continue; continue;
} }
if (safe_strcmp (to_uri_tests[i].filename, res)) if (safe_strcmp_filename (to_uri_tests[i].filename, res))
{ {
g_print ("roundtrip test %d failed, filename modified: " g_print ("roundtrip test %d failed, filename modified: "
" expected \"%s\", but got \"%s\"\n", " expected \"%s\", but got \"%s\"\n",