mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-31 22:23:39 +02:00
Moving tests/dirname-test.c to glib/tests/fileutils.c
Helps issue #1434
This commit is contained in:
committed by
Philip Withnall
parent
dce8d110d6
commit
9f760a7cc1
@@ -834,6 +834,67 @@ test_basename (void)
|
||||
g_free (b);
|
||||
}
|
||||
|
||||
static void
|
||||
test_dirname (void)
|
||||
{
|
||||
gsize i;
|
||||
struct {
|
||||
const gchar *filename;
|
||||
const gchar *dirname;
|
||||
} dirname_checks[] = {
|
||||
{ "/", "/" },
|
||||
{ "////", "/" },
|
||||
{ ".////", "." },
|
||||
{ ".", "." },
|
||||
{ "..", "." },
|
||||
{ "../", ".." },
|
||||
{ "..////", ".." },
|
||||
{ "", "." },
|
||||
{ "a/b", "a" },
|
||||
{ "a/b/", "a/b" },
|
||||
{ "c///", "c" },
|
||||
{ "/a/b", "/a" },
|
||||
{ "/a/b/", "/a/b" },
|
||||
#ifdef G_OS_WIN32
|
||||
{ "\\", "\\" },
|
||||
{ ".\\\\\\\\", "." },
|
||||
{ ".\\/\\/", "." },
|
||||
{ ".", "." },
|
||||
{ "..", "." },
|
||||
{ "..\\", ".." },
|
||||
{ "..\\\\\\\\", ".." },
|
||||
{ "..\\//\\", ".." },
|
||||
{ "", "." },
|
||||
{ "a\\b", "a" },
|
||||
{ "a\\b\\", "a\\b" },
|
||||
{ "\\a\\b", "\\a" },
|
||||
{ "\\a\\b\\", "\\a\\b" },
|
||||
{ "c\\\\\\", "c" },
|
||||
{ "c/\\\\", "c" },
|
||||
{ "a:", "a:." },
|
||||
{ "a:foo", "a:." },
|
||||
{ "a:foo\\bar", "a:foo" },
|
||||
{ "a:/foo", "a:/" },
|
||||
{ "a:/foo/bar", "a:/foo" },
|
||||
{ "a:/", "a:/" },
|
||||
{ "a://", "a:/" },
|
||||
{ "a:\\foo", "a:\\" },
|
||||
{ "a:\\", "a:\\" },
|
||||
{ "a:\\\\", "a:\\" },
|
||||
{ "a:\\/", "a:\\" },
|
||||
#endif
|
||||
};
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (dirname_checks); i++)
|
||||
{
|
||||
gchar *dirname;
|
||||
|
||||
dirname = g_path_get_dirname (dirname_checks[i].filename);
|
||||
g_assert_cmpstr (dirname, ==, dirname_checks[i].dirname);
|
||||
g_free (dirname);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_dir_make_tmp (void)
|
||||
{
|
||||
@@ -1839,6 +1900,7 @@ main (int argc,
|
||||
g_test_add_func ("/fileutils/format-size-for-display", test_format_size_for_display);
|
||||
g_test_add_func ("/fileutils/errors", test_file_errors);
|
||||
g_test_add_func ("/fileutils/basename", test_basename);
|
||||
g_test_add_func ("/fileutils/dirname", test_dirname);
|
||||
g_test_add_func ("/fileutils/dir-make-tmp", test_dir_make_tmp);
|
||||
g_test_add_func ("/fileutils/file-open-tmp", test_file_open_tmp);
|
||||
g_test_add_func ("/fileutils/mkstemp", test_mkstemp);
|
||||
|
Reference in New Issue
Block a user