18 /* This test is just to be used with valgrind */
24 s = g_build_path ("/", "hola///", "//mundo", NULL);
25 if (strcmp (s, "hola/mundo") != 0)
26 return FAILED ("1 Got wrong result, got: %s", s);
29 s = g_build_path ("/", "hola/", "/mundo", NULL);
30 if (strcmp (s, "hola/mundo") != 0)
31 return FAILED ("2 Got wrong result, got: %s", s);
34 s = g_build_path ("/", "hola/", "mundo", NULL);
35 if (strcmp (s, "hola/mundo") != 0)
36 return FAILED ("3 Got wrong result, got: %s", s);
39 s = g_build_path ("/", "hola", "/mundo", NULL);
40 if (strcmp (s, "hola/mundo") != 0)
41 return FAILED ("4 Got wrong result, got: %s", s);
44 s = g_build_path ("/", "/hello", "world/", NULL);
45 if (strcmp (s, "/hello/world/") != 0)
46 return FAILED ("5 Got wrong result, got: %s", s);
49 /* Now test multi-char-separators */
50 s = g_build_path ("**", "hello", "world", NULL);
51 if (strcmp (s, "hello**world") != 0)
52 return FAILED ("6 Got wrong result, got: %s", s);
55 s = g_build_path ("**", "hello**", "world", NULL);
56 if (strcmp (s, "hello**world") != 0)
57 return FAILED ("7 Got wrong result, got: %s", s);
60 s = g_build_path ("**", "hello**", "**world", NULL);
61 if (strcmp (s, "hello**world") != 0)
62 return FAILED ("8 Got wrong result, got: %s", s);
65 s = g_build_path ("**", "hello**", "**world", NULL);
66 if (strcmp (s, "hello**world") != 0)
67 return FAILED ("9 Got wrong result, got: %s", s);
70 s = g_build_path ("1234567890", "hello", "world", NULL);
71 if (strcmp (s, "hello1234567890world") != 0)
72 return FAILED ("10 Got wrong result, got: %s", s);
75 s = g_build_path ("1234567890", "hello1234567890", "1234567890world", NULL);
76 if (strcmp (s, "hello1234567890world") != 0)
77 return FAILED ("11 Got wrong result, got: %s", s);
80 s = g_build_path ("1234567890", "hello12345678901234567890", "1234567890world", NULL);
81 if (strcmp (s, "hello1234567890world") != 0)
82 return FAILED ("12 Got wrong result, got: %s", s);
86 s = g_build_path ("/", "a", "b", "c", "d", NULL);
87 if (strcmp (s, "a/b/c/d") != 0)
88 return FAILED ("13 Got wrong result, got: %s", s);
91 s = g_build_path ("/", "/a", "", "/c/", NULL);
92 if (strcmp (s, "/a/c/") != 0)
93 return FAILED ("14 Got wrong result, got: %s", s);
97 s = g_build_path ("/", NULL);
99 return FAILED ("must get a non-NULL return");
101 return FAILED ("must get an empty string");
111 s = g_build_filename ("a", "b", "c", "d", NULL);
113 if (strcmp (s, "a\\b\\c\\d") != 0)
115 if (strcmp (s, "a/b/c/d") != 0)
117 return FAILED ("1 Got wrong result, got: %s", s);
120 s = g_build_filename ("/", "a", NULL);
122 if (strcmp (s, "\\a") != 0)
124 if (strcmp (s, "/a") != 0)
126 return FAILED ("1 Got wrong result, got: %s", s);
129 s = g_build_filename ("/", "foo", "/bar", "tolo/", "/meo/", NULL);
130 if (strcmp (s, "/foo/bar/tolo/meo/") != 0)
131 return FAILED ("1 Got wrong result, got: %s", s);
143 s = g_path_get_dirname ("c:\\home\\miguel");
144 if (strcmp (s, "c:\\home") != 0)
145 return FAILED ("Expected c:\\home, got %s", s);
148 s = g_path_get_dirname ("c:\\home\\dingus\\");
149 if (strcmp (s, "c:\\home\\dingus") != 0)
150 return FAILED ("Expected c:\\home\\dingus, got %s", s);
153 s = g_path_get_dirname ("dir.c");
154 if (strcmp (s, ".") != 0)
155 return FAILED ("Expected `.', got %s", s);
158 s = g_path_get_dirname ("c:\\index.html");
159 if (strcmp (s, "c:") != 0)
160 return FAILED ("Expected [c:], got [%s]", s);
162 s = g_path_get_dirname ("/home/miguel");
163 if (strcmp (s, "/home") != 0)
164 return FAILED ("Expected /home, got %s", s);
167 s = g_path_get_dirname ("/home/dingus/");
168 if (strcmp (s, "/home/dingus") != 0)
169 return FAILED ("Expected /home/dingus, got %s", s);
172 s = g_path_get_dirname ("dir.c");
173 if (strcmp (s, ".") != 0)
174 return FAILED ("Expected `.', got %s", s);
177 s = g_path_get_dirname ("/index.html");
178 if (strcmp (s, "/") != 0)
179 return FAILED ("Expected [/], got [%s]", s);
190 s = g_path_get_basename ("");
191 if (strcmp (s, ".") != 0)
192 return FAILED ("Expected `.', got %s", s);
195 s = g_path_get_basename ("c:\\home\\dingus\\");
196 if (strcmp (s, "dingus") != 0)
197 return FAILED ("1 Expected dingus, got %s", s);
200 s = g_path_get_basename ("c:\\home\\dingus");
201 if (strcmp (s, "dingus") != 0)
202 return FAILED ("2 Expected dingus, got %s", s);
205 s = g_path_get_basename ("");
206 if (strcmp (s, ".") != 0)
207 return FAILED ("Expected `.', got %s", s);
210 s = g_path_get_basename ("/home/dingus/");
211 if (strcmp (s, "dingus") != 0)
212 return FAILED ("1 Expected dingus, got %s", s);
215 s = g_path_get_basename ("/home/dingus");
216 if (strcmp (s, "dingus") != 0)
217 return FAILED ("2 Expected dingus, got %s", s);
228 const gchar *searchfor = "explorer.exe";
230 const gchar *searchfor = "ls";
232 s = g_find_program_in_path (searchfor);
234 return FAILED ("No %s on this system?", searchfor);
243 const char *path = g_getenv ("PATH");
245 const gchar *searchfor = "test_eglib.exe";
247 const gchar *searchfor = "test-glib";
250 g_setenv ("PATH", "", TRUE);
251 s = g_find_program_in_path ("ls");
253 g_setenv ("PATH", path, TRUE);
254 return FAILED ("Found something interesting here: %s", s);
257 s = g_find_program_in_path (searchfor);
259 g_setenv ("PATH", path, TRUE);
260 return FAILED ("It should find '%s' in the current directory.", searchfor);
263 g_setenv ("PATH", path, TRUE);
267 #ifndef DISABLE_FILESYSTEM_TESTS
271 char *dir = g_get_current_dir ();
273 const gchar *newdir = "C:\\Windows";
275 const gchar *newdir = "/bin";
279 return FAILED ("No current directory?");
282 if (chdir (newdir) == -1)
283 return FAILED ("No %s?", newdir);
285 dir = g_get_current_dir ();
286 if (strcmp (dir, newdir) != 0)
287 return FAILED("Did not go to %s?", newdir);
303 const char *home = g_get_home_dir ();
304 const char *tmp = g_get_tmp_dir ();
307 return FAILED ("Where did my home go?");
310 return FAILED ("Where did my /tmp go?");
315 static Test path_tests [] = {
316 {"g_build_filename", test_buildfname},
317 {"g_buildpath", test_buildpath},
318 {"g_path_get_dirname", test_dirname},
319 {"g_path_get_basename", test_basename},
320 {"g_find_program_in_path", test_ppath},
321 {"g_find_program_in_path2", test_ppath2},
322 {"test_cwd", test_cwd },
323 {"test_misc", test_misc },
327 DEFINE_TEST_GROUP_INIT(path_tests_init, path_tests)