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);
104 s = g_build_filename ("a", "b", "c", "d", NULL);
106 if (strcmp (s, "a\\b\\c\\d") != 0)
108 if (strcmp (s, "a/b/c/d") != 0)
110 return FAILED ("1 Got wrong result, got: %s", s);
122 s = g_path_get_dirname ("c:\\home\\miguel");
123 if (strcmp (s, "c:\\home") != 0)
124 return FAILED ("Expected c:\\home, got %s", s);
127 s = g_path_get_dirname ("c:\\home\\dingus\\");
128 if (strcmp (s, "c:\\home\\dingus") != 0)
129 return FAILED ("Expected c:\\home\\dingus, got %s", s);
132 s = g_path_get_dirname ("dir.c");
133 if (strcmp (s, ".") != 0)
134 return FAILED ("Expected `.', got %s", s);
137 s = g_path_get_dirname ("c:\\index.html");
138 if (strcmp (s, "c:") != 0)
139 return FAILED ("Expected [c:], got [%s]", s);
141 s = g_path_get_dirname ("/home/miguel");
142 if (strcmp (s, "/home") != 0)
143 return FAILED ("Expected /home, got %s", s);
146 s = g_path_get_dirname ("/home/dingus/");
147 if (strcmp (s, "/home/dingus") != 0)
148 return FAILED ("Expected /home/dingus, got %s", s);
151 s = g_path_get_dirname ("dir.c");
152 if (strcmp (s, ".") != 0)
153 return FAILED ("Expected `.', got %s", s);
156 s = g_path_get_dirname ("/index.html");
157 if (strcmp (s, "/") != 0)
158 return FAILED ("Expected [/], got [%s]", s);
169 s = g_path_get_basename ("");
170 if (strcmp (s, ".") != 0)
171 return FAILED ("Expected `.', got %s", s);
174 s = g_path_get_basename ("c:\\home\\dingus\\");
175 if (strcmp (s, "dingus") != 0)
176 return FAILED ("1 Expected dingus, got %s", s);
179 s = g_path_get_basename ("c:\\home\\dingus");
180 if (strcmp (s, "dingus") != 0)
181 return FAILED ("2 Expected dingus, got %s", s);
184 s = g_path_get_basename ("");
185 if (strcmp (s, ".") != 0)
186 return FAILED ("Expected `.', got %s", s);
189 s = g_path_get_basename ("/home/dingus/");
190 if (strcmp (s, "dingus") != 0)
191 return FAILED ("1 Expected dingus, got %s", s);
194 s = g_path_get_basename ("/home/dingus");
195 if (strcmp (s, "dingus") != 0)
196 return FAILED ("2 Expected dingus, got %s", s);
207 const gchar *searchfor = "explorer.exe";
209 const gchar *searchfor = "ls";
211 s = g_find_program_in_path (searchfor);
213 return FAILED ("No %s on this system?", searchfor);
222 const char *path = g_getenv ("PATH");
224 const gchar *searchfor = "test_eglib.exe";
226 const gchar *searchfor = "test-glib";
229 g_setenv ("PATH", "", TRUE);
230 s = g_find_program_in_path ("ls");
232 g_setenv ("PATH", path, TRUE);
233 return FAILED ("Found something interesting here: %s", s);
236 s = g_find_program_in_path (searchfor);
238 g_setenv ("PATH", path, TRUE);
239 return FAILED ("It should find '%s' in the current directory.", searchfor);
242 g_setenv ("PATH", path, TRUE);
249 char *dir = g_get_current_dir ();
251 const gchar *newdir = "C:\\Windows";
253 const gchar *newdir = "/bin";
257 return FAILED ("No current directory?");
260 if (chdir (newdir) == -1)
261 return FAILED ("No %s?", newdir);
263 dir = g_get_current_dir ();
264 if (strcmp (dir, newdir) != 0)
265 return FAILED("Did not go to %s?", newdir);
274 const char *home = g_get_home_dir ();
275 const char *tmp = g_get_tmp_dir ();
278 return FAILED ("Where did my home go?");
281 return FAILED ("Where did my /tmp go?");
286 static Test path_tests [] = {
287 {"g_buildpath", test_buildpath},
288 {"g_build_filename", test_buildfname},
289 {"g_path_get_dirname", test_dirname},
290 {"g_path_get_basename", test_basename},
291 {"g_find_program_in_path", test_ppath},
292 {"g_find_program_in_path2", test_ppath2},
293 {"test_cwd", test_cwd },
294 {"test_misc", test_misc },
298 DEFINE_TEST_GROUP_INIT(path_tests_init, path_tests)