summaryrefslogtreecommitdiff
path: root/tests/testglib.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2003-08-16 19:45:25 +0000
committerTor Lillqvist <tml@src.gnome.org>2003-08-16 19:45:25 +0000
commit55d624d80cbc962c0dfbdecfba7e128b3b332e31 (patch)
tree21e2fe9fb1ca723a72d8b726a7803916df5ae416 /tests/testglib.c
parented23bef565d1551e8ce4b5dcb49c2c11a96eb4a9 (diff)
downloadglib-55d624d80cbc962c0dfbdecfba7e128b3b332e31.tar.gz
Fix #117925 (Dov Grobgeld):
2003-08-16 Tor Lillqvist <tml@iki.fi> Fix #117925 (Dov Grobgeld): * glib/gutils.c (g_find_program_in_path, g_basename, g_path_get_basename, g_path_is_absolute, g_path_skip_root, g_path_get_dirname, g_get_any_init): On Win32, look also for slashes ('/') as pathname separators. * glib/gfileutils.c (g_file_open_tmp): Ditto. If the template contains a pathname separator, include the actual one in the error message, instead of always the canonical one. (g_build_filename): Separate implementation on Win32 that looks for either slash or backslash. Document Unix/Windows differences. * tests/testglib.c * tests/strfunc-test.c: Test above functionality on Win32.
Diffstat (limited to 'tests/testglib.c')
-rw-r--r--tests/testglib.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/tests/testglib.c b/tests/testglib.c
index 5695754b4..54a9153bd 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -336,7 +336,6 @@ main (int argc,
gchar *filename;
gchar *dirname;
} dirname_checks[] = {
-#ifndef G_OS_WIN32
{ "/", "/" },
{ "////", "/" },
{ ".////", "." },
@@ -345,14 +344,16 @@ main (int argc,
{ "a/b", "a" },
{ "a/b/", "a/b" },
{ "c///", "c" },
-#else
+#ifdef G_OS_WIN32
{ "\\", "\\" },
{ ".\\\\\\\\", "." },
{ "..\\", ".." },
{ "..\\\\\\\\", ".." },
{ "a\\b", "a" },
- { "a\\b\\", "a\\b" },
- { "c\\\\\\", "c" },
+ { "a\\b/", "a\\b" },
+ { "a/b\\", "a/b" },
+ { "c\\\\/", "c" },
+ { "//\\", "/" },
#endif
#ifdef G_WITH_CYGWIN
{ "//server/share///x", "//server/share" },
@@ -367,13 +368,12 @@ main (int argc,
gchar *filename;
gchar *without_root;
} skip_root_checks[] = {
-#ifndef G_OS_WIN32
{ "/", "" },
{ "//", "" },
{ "/foo", "foo" },
{ "//foo", "foo" },
{ "a/b", NULL },
-#else
+#ifdef G_OS_WIN32
{ "\\", "" },
{ "\\foo", "foo" },
{ "\\\\server\\foo", "" },
@@ -448,6 +448,15 @@ main (int argc,
g_assert (strcmp (string, "file") == 0);
g_free (string);
g_print ("ok\n");
+#ifdef G_OS_WIN32
+ string = g_path_get_basename ("/foo/dir/");
+ g_assert (strcmp (string, "dir") == 0);
+ g_free (string);
+ string = g_path_get_basename ("/foo/file");
+ g_assert (strcmp (string, "file") == 0);
+ g_free (string);
+ g_print ("ok\n");
+#endif
g_print ("checking g_path_get_dirname()...");
for (i = 0; i < n_dirname_checks; i++)
@@ -1171,6 +1180,11 @@ main (int argc,
g_print ("ok\n");
+ if (g_get_charset (&string))
+ g_print ("current charset is UTF-8: %s\n", string);
+ else
+ g_print ("current charset is not UTF-8: %s\n", string);
+
#ifdef G_PLATFORM_WIN32
g_print ("current locale: %s\n", g_win32_getlocale ());
g_print ("GLib DLL name tested for: %s\n", glib_dll);
@@ -1235,6 +1249,18 @@ main (int argc,
close (fd);
g_clear_error (&error);
+#ifdef G_OS_WIN32
+ strcpy (template, "zap/barXXXXXX");
+ fd = g_file_open_tmp (template, &name_used, &error);
+ if (fd != -1)
+ g_print ("g_file_open_tmp works even if template contains '/'\n");
+ else
+ g_print ("g_file_open_tmp correctly returns error: %s\n",
+ error->message);
+ close (fd);
+ g_clear_error (&error);
+#endif
+
strcpy (template, "zapXXXXXX");
fd = g_file_open_tmp (template, &name_used, &error);
if (fd == -1)