1
1

More tests for canonicalize_pathname().

(custom_canonicalize_pathname): fix wrong condition. Remove redundant
break.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2013-09-20 13:13:56 +04:00
родитель e78b1fdf66
Коммит 61dc030772
2 изменённых файлов: 48 добавлений и 2 удалений

Просмотреть файл

@ -844,7 +844,7 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
while (p >= lpath && *p != PATH_SEP)
p--;
if (p != NULL)
if (p >= lpath)
continue;
}
#endif /* HAVE_CHARSET */
@ -856,7 +856,6 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags)
else
s[-1] = '\0';
}
break;
}
break;

Просмотреть файл

@ -27,6 +27,10 @@
#include "tests/mctest.h"
#ifdef HAVE_CHARSET
#include "lib/charsets.h"
#endif
#include "lib/strutil.h"
#include "lib/util.h"
#include "lib/vfs/xdirentry.h"
@ -48,6 +52,11 @@ setup (void)
init_localfs ();
vfs_setup_work_dir ();
#ifdef HAVE_CHARSET
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
load_codepages_list ();
#endif
vfs_s_init_class (&vfs_test_ops, &test_subclass);
vfs_test_ops.name = "testfs";
@ -63,6 +72,10 @@ setup (void)
static void
teardown (void)
{
#ifdef HAVE_CHARSET
free_codepages_list ();
#endif
vfs_shut ();
str_uninit_strings ();
}
@ -117,6 +130,40 @@ static const struct test_canonicalize_path_ds
"ftp://user/../../",
".."
},
#ifdef HAVE_CHARSET
{ /* 10. Supported encoding */
"/b/#enc:utf-8/../c",
"/c"
},
{ /* 11. Unsupported encoding */
"/b/#enc:aaaa/../c",
"/b/c"
},
{ /* 12. Supported encoding */
"/b/../#enc:utf-8/c",
"/#enc:utf-8/c"
},
{ /* 13. Unsupported encoding */
"/b/../#enc:aaaa/c",
"/#enc:aaaa/c"
},
{ /* 14. Supported encoding */
"/b/c/#enc:utf-8/..",
"/b"
},
{ /* 15. Unsupported encoding */
"/b/c/#enc:aaaa/..",
"/b/c"
},
{ /* 16. Supported encoding */
"/b/c/../#enc:utf-8",
"/b/#enc:utf-8"
},
{ /* 17. Unsupported encoding */
"/b/c/../#enc:aaaa",
"/b/#enc:aaaa"
},
#endif /* HAVE_CHARSET */
};
/* *INDENT-ON* */