mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
Tests tweak and cleanup in case of --disable-charset option usage.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
e7fb3526f3
commit
af3dd96e7b
@ -14,7 +14,6 @@ TESTS = \
|
||||
path_cmp \
|
||||
path_len \
|
||||
path_manipulations \
|
||||
path_recode \
|
||||
path_serialize \
|
||||
relative_cd \
|
||||
tempdir \
|
||||
@ -24,6 +23,10 @@ TESTS = \
|
||||
vfs_split \
|
||||
vfs_s_get_path
|
||||
|
||||
if CHARSET
|
||||
TESTS += path_recode
|
||||
endif
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
canonicalize_pathname_SOURCES = \
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -49,13 +47,17 @@ setup (void)
|
||||
vfs_setup_work_dir ();
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
@ -79,9 +81,10 @@ START_TEST (test_path_compare)
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", ==0);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_cmp_one_check ("/#enc:KOI8-R/тестовый/путь", "/тестовый/путь", <0);
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/#enc:KOI8-R/тестовый/путь", >0);
|
||||
#endif
|
||||
|
||||
path_cmp_one_check (NULL, "/тестовый/путь", -1);
|
||||
path_cmp_one_check ("/тестовый/путь", NULL, -1);
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -49,12 +47,18 @@ setup (void)
|
||||
vfs_setup_work_dir ();
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
@ -74,8 +78,9 @@ START_TEST (test_path_length)
|
||||
size_t result;
|
||||
|
||||
path_len_one_check ("/тестовый/путь", 26);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_len_one_check ("/#enc:KOI8-R/тестовый/путь", 38);
|
||||
#endif
|
||||
path_len_one_check (NULL, 0);
|
||||
}
|
||||
END_TEST
|
||||
|
@ -26,11 +26,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -73,13 +71,17 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops3);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
@ -127,12 +129,14 @@ START_TEST (test_vfs_path_tokens_count)
|
||||
fail_unless (tokens_count == 5, "actual: %zu; expected: 5\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vpath = vfs_path_from_str (
|
||||
"/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33"
|
||||
);
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
fail_unless (tokens_count == 11, "actual: %zu; expected: 11\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
#endif
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@ -176,11 +180,13 @@ START_TEST (test_vfs_path_tokens_get)
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS */
|
||||
check_token_str ("test3://path1/path2/path3/path4", 1, 2, "path2/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS with encoding */
|
||||
#ifdef HAVE_CHARSET
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS with encoding */
|
||||
check_token_str ("test3://path1/path2/test3://#enc:KOI8-R/path3/path4", 1, 2, "path2/test3://#enc:KOI8-R/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 with encoding */
|
||||
check_token_str ("#enc:KOI8-R/path1/path2/path3/path4", 1, 2, "#enc:KOI8-R/path2/path3");
|
||||
#endif
|
||||
|
||||
/* get 'path2/path3' by 1,2 from non-LOCAL VFS */
|
||||
check_token_str ("test2://path1/path2/path3/path4", 1, 2, "test2://path2/path3");
|
||||
@ -213,7 +219,11 @@ START_TEST (test_vfs_path_append_vpath)
|
||||
{
|
||||
vfs_path_t *vpath1, *vpath2, *vpath3;
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
vpath1 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33");
|
||||
#else
|
||||
vpath1 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://bla-bla/some/path/test3://111/22/33");
|
||||
#endif
|
||||
vpath2 = vfs_path_from_str("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/");
|
||||
|
||||
vpath3 = vfs_path_append_vpath_new (vpath1, vpath2, NULL);
|
||||
|
@ -31,10 +31,6 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
|
@ -31,11 +31,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -77,19 +75,24 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops3);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
#ifdef HAVE_CHARSET
|
||||
load_codepages_list ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
#ifdef HAVE_CHARSET
|
||||
free_codepages_list ();
|
||||
#endif
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#ifdef HAVE_CHARSET
|
||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/#enc:KOI8-R/bla-bla/some/path#test3/111/22/33"
|
||||
#define ETALON_PATH_URL_STR "/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://#enc:KOI8-R/bla-bla/some/path/test3://111/22/33"
|
||||
#define ETALON_SERIALIZED_PATH \
|
||||
@ -113,6 +116,30 @@ teardown (void)
|
||||
"p4:pathv9:111/22/33" \
|
||||
"p10:class-namev7:testfs3" \
|
||||
"p10:vfs_prefixv5:test3"
|
||||
#else
|
||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2/bla-bla/some/path#test3/111/22/33"
|
||||
#define ETALON_PATH_URL_STR "/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/test2://bla-bla/some/path/test3://111/22/33"
|
||||
#define ETALON_SERIALIZED_PATH \
|
||||
"g14:path-element-0" \
|
||||
"p4:pathv12:/local/path/" \
|
||||
"p10:class-namev7:localfs" \
|
||||
"g14:path-element-1" \
|
||||
"p4:pathv18:bla-bla/some/path/" \
|
||||
"p10:class-namev7:testfs1" \
|
||||
"p10:vfs_prefixv5:test1" \
|
||||
"p4:userv4:user" \
|
||||
"p8:passwordv4:pass" \
|
||||
"p4:hostv9:some.host" \
|
||||
"p4:portv5:12345" \
|
||||
"g14:path-element-2" \
|
||||
"p4:pathv17:bla-bla/some/path" \
|
||||
"p10:class-namev7:testfs2" \
|
||||
"p10:vfs_prefixv5:test2" \
|
||||
"g14:path-element-3" \
|
||||
"p4:pathv9:111/22/33" \
|
||||
"p10:class-namev7:testfs3" \
|
||||
"p10:vfs_prefixv5:test3"
|
||||
#endif
|
||||
|
||||
START_TEST (test_path_serialize_deserialize)
|
||||
{
|
||||
|
@ -26,12 +26,6 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#include "lib/charsets.h"
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/path.h"
|
||||
@ -65,14 +59,11 @@ setup (void)
|
||||
vfs_register_class (&vfs_test_ops1);
|
||||
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
load_codepages_list ();
|
||||
}
|
||||
|
||||
static void
|
||||
teardown (void)
|
||||
{
|
||||
free_codepages_list ();
|
||||
|
||||
vfs_shut ();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
@ -31,11 +31,9 @@
|
||||
|
||||
#include "lib/global.c"
|
||||
|
||||
#ifndef HAVE_CHARSET
|
||||
#define HAVE_CHARSET 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#include "lib/charsets.h"
|
||||
#endif
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
@ -201,7 +199,7 @@ START_TEST (test_vfs_path_from_to_partial_string_by_class)
|
||||
}
|
||||
END_TEST
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
#define encoding_check( input , etalon ) \
|
||||
{ \
|
||||
vfs_path_t *vpath; \
|
||||
@ -284,6 +282,7 @@ START_TEST (test_vfs_path_encoding_at_end)
|
||||
}
|
||||
|
||||
END_TEST
|
||||
#endif /* HAVE_CHARSET */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#undef ETALON_PATH_STR
|
||||
@ -323,8 +322,10 @@ main (void)
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string);
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string2);
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_partial_string_by_class);
|
||||
#ifdef HAVE_CHARSET
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string_encoding);
|
||||
tcase_add_test (tc_core, test_vfs_path_encoding_at_end);
|
||||
#endif
|
||||
tcase_add_test (tc_core, test_vfs_path_from_to_string_uri);
|
||||
/* *********************************** */
|
||||
|
||||
|
@ -91,6 +91,7 @@ free_my_statfs (void)
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
int
|
||||
select_charset (int center_y, int center_x, int current_charset, gboolean seldisplay)
|
||||
{
|
||||
@ -101,6 +102,7 @@ select_charset (int center_y, int center_x, int current_charset, gboolean seldis
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
update_xterm_title_path (void)
|
||||
|
Loading…
Reference in New Issue
Block a user