8 /* This test is just to be used with valgrind */
14 s = g_build_path ("/", "hola///", "//mundo", NULL);
15 if (strcmp (s, "hola/mundo") != 0)
16 return FAILED ("1 Got wrong result, got: %s", s);
19 s = g_build_path ("/", "hola/", "/mundo", NULL);
20 if (strcmp (s, "hola/mundo") != 0)
21 return FAILED ("2 Got wrong result, got: %s", s);
24 s = g_build_path ("/", "hola/", "mundo", NULL);
25 if (strcmp (s, "hola/mundo") != 0)
26 return FAILED ("3 Got wrong result, got: %s", s);
29 s = g_build_path ("/", "hola", "/mundo", NULL);
30 if (strcmp (s, "hola/mundo") != 0)
31 return FAILED ("4 Got wrong result, got: %s", s);
34 s = g_build_path ("/", "/hello", "world/", NULL);
35 if (strcmp (s, "/hello/world/") != 0)
36 return FAILED ("5 Got wrong result, got: %s", s);
39 /* Now test multi-char-separators */
40 s = g_build_path ("**", "hello", "world", NULL);
41 if (strcmp (s, "hello**world") != 0)
42 return FAILED ("6 Got wrong result, got: %s", s);
45 s = g_build_path ("**", "hello**", "world", NULL);
46 if (strcmp (s, "hello**world") != 0)
47 return FAILED ("7 Got wrong result, got: %s", s);
50 s = g_build_path ("**", "hello**", "**world", NULL);
51 if (strcmp (s, "hello**world") != 0)
52 return FAILED ("8 Got wrong result, got: %s", s);
55 s = g_build_path ("**", "hello**", "**world", NULL);
56 if (strcmp (s, "hello**world") != 0)
57 return FAILED ("9 Got wrong result, got: %s", s);
60 s = g_build_path ("1234567890", "hello", "world", NULL);
61 if (strcmp (s, "hello1234567890world") != 0)
62 return FAILED ("10 Got wrong result, got: %s", s);
65 s = g_build_path ("1234567890", "hello1234567890", "1234567890world", NULL);
66 if (strcmp (s, "hello1234567890world") != 0)
67 return FAILED ("11 Got wrong result, got: %s", s);
70 s = g_build_path ("1234567890", "hello12345678901234567890", "1234567890world", NULL);
71 if (strcmp (s, "hello1234567890world") != 0)
72 return FAILED ("12 Got wrong result, got: %s", s);
76 s = g_build_path ("/", "a", "b", "c", "d", NULL);
77 if (strcmp (s, "a/b/c/d") != 0)
78 return FAILED ("13 Got wrong result, got: %s", s);
89 s = g_build_filename ("a", "b", "c", "d", NULL);
90 if (strcmp (s, "a/b/c/d") != 0)
91 return FAILED ("1 Got wrong result, got: %s", s);
102 s = g_path_get_dirname ("/home/miguel");
103 if (strcmp (s, "/home") != 0)
104 return FAILED ("Expected /home, got %s", s);
107 s = g_path_get_dirname ("/home/dingus/");
108 if (strcmp (s, "/home/dingus") != 0)
109 return FAILED ("Expected /home/dingus, got %s", s);
120 s = g_path_get_basename ("");
121 if (strcmp (s, ".") != 0)
122 return FAILED ("Expected `.', got %s", s);
125 s = g_path_get_basename ("/home/dingus/");
126 if (strcmp (s, "dingus") != 0)
127 return FAILED ("1 Expected dingus, got %s", s);
130 s = g_path_get_basename ("/home/dingus");
131 if (strcmp (s, "dingus") != 0)
132 return FAILED ("2 Expected dingus, got %s", s);
143 s = g_find_program_in_path ("ls");
145 return FAILED ("No shell on this system (This assumes Unix)?");
154 const char *path = g_getenv ("PATH");
156 g_setenv ("PATH", "", TRUE);
157 s = g_find_program_in_path ("ls");
159 g_setenv ("PATH", path, TRUE);
160 return FAILED ("Found something interesting here: %s", s);
163 s = g_find_program_in_path ("test-glib");
165 g_setenv ("PATH", path, TRUE);
166 return FAILED ("It should find 'test-glib' in the current directory.");
169 g_setenv ("PATH", path, TRUE);
176 char *dir = g_get_current_dir ();
179 return FAILED ("No current directory?");
182 if (chdir ("/bin") == -1)
183 return FAILED ("No /bin?");
185 dir = g_get_current_dir ();
186 if (strcmp (dir, "/bin") != 0)
187 return FAILED("Did not go to /bin?");
196 const char *home = g_get_home_dir ();
197 const char *tmp = g_get_tmp_dir ();
200 return FAILED ("Where did my home go?");
203 return FAILED ("Where did my /tmp go?");
208 static Test path_tests [] = {
209 {"g_buildpath", test_buildpath},
210 {"g_build_filename", test_buildfname},
211 {"g_path_get_dirname", test_dirname},
212 {"g_path_get_basename", test_basename},
213 {"g_find_program_in_path", test_ppath},
214 {"g_find_program_in_path2", test_ppath2},
215 {"test_cwd", test_cwd },
216 {"test_misc", test_misc },
220 DEFINE_TEST_GROUP_INIT(path_tests_init, path_tests)