From af3dd96e7ba621b0f2b085153ffdeebf64e3311c Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 7 Jun 2012 15:17:18 +0400 Subject: [PATCH] Tests tweak and cleanup in case of --disable-charset option usage. Signed-off-by: Andrew Borodin --- tests/lib/vfs/Makefile.am | 5 ++- tests/lib/vfs/path_cmp.c | 13 +++++--- tests/lib/vfs/path_len.c | 15 ++++++--- tests/lib/vfs/path_manipulations.c | 20 ++++++++--- tests/lib/vfs/path_recode.c | 4 --- tests/lib/vfs/path_serialize.c | 35 +++++++++++++++++--- tests/lib/vfs/relative_cd.c | 9 ----- tests/lib/vfs/vfs_path_string_convert.c | 11 +++--- tests/src/filemanager/do_panel_cd_stub_env.c | 2 ++ 9 files changed, 76 insertions(+), 38 deletions(-) diff --git a/tests/lib/vfs/Makefile.am b/tests/lib/vfs/Makefile.am index 86d18745a..4114e7063 100644 --- a/tests/lib/vfs/Makefile.am +++ b/tests/lib/vfs/Makefile.am @@ -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 = \ diff --git a/tests/lib/vfs/path_cmp.c b/tests/lib/vfs/path_cmp.c index 08aa4419a..fdedab41c 100644 --- a/tests/lib/vfs/path_cmp.c +++ b/tests/lib/vfs/path_cmp.c @@ -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); diff --git a/tests/lib/vfs/path_len.c b/tests/lib/vfs/path_len.c index c835b05f7..888f85d9a 100644 --- a/tests/lib/vfs/path_len.c +++ b/tests/lib/vfs/path_len.c @@ -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 diff --git a/tests/lib/vfs/path_manipulations.c b/tests/lib/vfs/path_manipulations.c index 795704ccb..1dce032d9 100644 --- a/tests/lib/vfs/path_manipulations.c +++ b/tests/lib/vfs/path_manipulations.c @@ -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); diff --git a/tests/lib/vfs/path_recode.c b/tests/lib/vfs/path_recode.c index 8c67aedae..1f5b3571b 100644 --- a/tests/lib/vfs/path_recode.c +++ b/tests/lib/vfs/path_recode.c @@ -31,10 +31,6 @@ #include "lib/global.c" -#ifndef HAVE_CHARSET -#define HAVE_CHARSET 1 -#endif - #include "lib/charsets.h" #include "lib/strutil.h" diff --git a/tests/lib/vfs/path_serialize.c b/tests/lib/vfs/path_serialize.c index 967760ea5..9f2fffbcf 100644 --- a/tests/lib/vfs/path_serialize.c +++ b/tests/lib/vfs/path_serialize.c @@ -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) { diff --git a/tests/lib/vfs/relative_cd.c b/tests/lib/vfs/relative_cd.c index 930bb9f58..7e6101da2 100644 --- a/tests/lib/vfs/relative_cd.c +++ b/tests/lib/vfs/relative_cd.c @@ -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 (); } diff --git a/tests/lib/vfs/vfs_path_string_convert.c b/tests/lib/vfs/vfs_path_string_convert.c index df7eb245e..5016b6b56 100644 --- a/tests/lib/vfs/vfs_path_string_convert.c +++ b/tests/lib/vfs/vfs_path_string_convert.c @@ -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); /* *********************************** */ diff --git a/tests/src/filemanager/do_panel_cd_stub_env.c b/tests/src/filemanager/do_panel_cd_stub_env.c index 31e940b56..dea3ba2a0 100644 --- a/tests/src/filemanager/do_panel_cd_stub_env.c +++ b/tests/src/filemanager/do_panel_cd_stub_env.c @@ -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)