[profiler] Split method_leave callback into a method_tail_call callback.
[mono.git] / eglib / test / path.c
index aaf5685d75fccfd920c0d9e1fa2e5609739657f0..e3832a04be493815e423203c66616f86418e33db 100644 (file)
@@ -20,6 +20,8 @@ RESULT
 test_buildpath ()
 {
        char *s;
+       char *buffer = "var/private";
+       char *dir = "/";
        
        s = g_build_path ("/", "hola///", "//mundo", NULL);
        if (strcmp (s, "hola/mundo") != 0)
@@ -99,6 +101,16 @@ test_buildpath ()
                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;
 }
@@ -117,15 +129,16 @@ test_buildfname ()
                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);
@@ -145,6 +158,11 @@ test_dirname ()
                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);
@@ -197,10 +215,20 @@ test_basename ()
                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)