test_buildpath ()
{
char *s;
+ char *buffer = "var/private";
+ char *dir = "/";
s = g_build_path ("/", "hola///", "//mundo", NULL);
if (strcmp (s, "hola/mundo") != 0)
return FAILED ("must get a non-NULL return");
if (s [0] != 0)
return FAILED ("must get an empty string");
+
+ // This is to test the regression introduced by Levi for the Windows support
+ // that code errouneously read below the allowed area (in this case dir [-1]).
+ // and caused all kinds of random errors.
+ dir = "//";
+ dir++;
+ s = g_build_filename (dir, buffer, NULL);
+ if (s [0] != '/')
+ return FAILED ("Must have a '/' at the start");
+
g_free (s);
return OK;
}
return FAILED ("1 Got wrong result, got: %s", s);
g_free (s);
- s = g_build_filename ("/", "a", NULL);
#ifdef G_OS_WIN32
- if (strcmp (s, "\\a") != 0)
+ s = g_build_filename ("C:\\", "a", NULL);
+ if (strcmp (s, "C:\\a") != 0)
#else
+ s = g_build_filename ("/", "a", NULL);
if (strcmp (s, "/a") != 0)
#endif
return FAILED ("1 Got wrong result, got: %s", s);
-#ifndef OS_WIN32
+#ifndef G_OS_WIN32
s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL);
if (strcmp (s, "/foo/bar/tolo/meo/") != 0)
return FAILED ("1 Got wrong result, got: %s", s);
return FAILED ("Expected c:\\home, got %s", s);
g_free (s);
+ s = g_path_get_dirname ("c:/home/miguel");
+ if (strcmp (s, "c:/home") != 0)
+ return FAILED ("Expected c:/home, got %s", s);
+ g_free (s);
+
s = g_path_get_dirname ("c:\\home\\dingus\\");
if (strcmp (s, "c:\\home\\dingus") != 0)
return FAILED ("Expected c:\\home\\dingus, got %s", s);
return FAILED ("1 Expected dingus, got %s", s);
g_free (s);
+ s = g_path_get_basename ("c:/home/dingus/");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("1 Expected dingus, got %s", s);
+ g_free (s);
+
s = g_path_get_basename ("c:\\home\\dingus");
if (strcmp (s, "dingus") != 0)
return FAILED ("2 Expected dingus, got %s", s);
g_free (s);
+
+ s = g_path_get_basename ("c:/home/dingus");
+ if (strcmp (s, "dingus") != 0)
+ return FAILED ("2 Expected dingus, got %s", s);
+ g_free (s);
#else
s = g_path_get_basename ("");
if (strcmp (s, ".") != 0)