Ticket #2944: Prepare for release mc-4.8.8
Code indentation in tests. Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
4bbeaf9f38
Коммит
5f99213a5e
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/library_independ"
|
||||
|
||||
@ -33,10 +33,14 @@
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_library_independ)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
@ -55,37 +55,42 @@ teardown (void)
|
||||
g_free (result); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_mc_build_filename)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *result;
|
||||
|
||||
check_mc_build_filename(("test", "path", NULL), "test/path");
|
||||
check_mc_build_filename (("test", "path", NULL), "test/path");
|
||||
|
||||
check_mc_build_filename(("/test", "path/", NULL), "/test/path");
|
||||
check_mc_build_filename (("/test", "path/", NULL), "/test/path");
|
||||
|
||||
check_mc_build_filename(("/test", "pa/th", NULL), "/test/pa/th");
|
||||
check_mc_build_filename (("/test", "pa/th", NULL), "/test/pa/th");
|
||||
|
||||
check_mc_build_filename(("/test", "#vfsprefix:", "path ", NULL), "/test/#vfsprefix:/path ");
|
||||
check_mc_build_filename (("/test", "#vfsprefix:", "path ", NULL), "/test/#vfsprefix:/path ");
|
||||
|
||||
check_mc_build_filename(("/test", "vfsprefix://", "path ", NULL), "/test/vfsprefix://path ");
|
||||
check_mc_build_filename (("/test", "vfsprefix://", "path ", NULL), "/test/vfsprefix://path ");
|
||||
|
||||
check_mc_build_filename(("/test", "vfs/../prefix:///", "p\\///ath", NULL), "/test/prefix://p\\/ath");
|
||||
check_mc_build_filename (("/test", "vfs/../prefix:///", "p\\///ath", NULL),
|
||||
"/test/prefix://p\\/ath");
|
||||
|
||||
check_mc_build_filename(("/test", "path", "..", "/test", "path/", NULL), "/test/test/path");
|
||||
check_mc_build_filename (("/test", "path", "..", "/test", "path/", NULL), "/test/test/path");
|
||||
|
||||
check_mc_build_filename(("", "path", NULL), "path");
|
||||
check_mc_build_filename (("", "path", NULL), "path");
|
||||
|
||||
check_mc_build_filename(("", "/path", NULL), "path");
|
||||
check_mc_build_filename (("", "/path", NULL), "path");
|
||||
|
||||
check_mc_build_filename(("path", "", NULL), "path");
|
||||
check_mc_build_filename (("path", "", NULL), "path");
|
||||
|
||||
check_mc_build_filename(("/path", "", NULL), "/path");
|
||||
check_mc_build_filename (("/path", "", NULL), "/path");
|
||||
|
||||
check_mc_build_filename(("pa", "", "th", NULL), "pa/th");
|
||||
check_mc_build_filename (("pa", "", "th", NULL), "pa/th");
|
||||
|
||||
check_mc_build_filename(("/pa", "", "/th", NULL), "/pa/th");
|
||||
check_mc_build_filename (("/pa", "", "/th", NULL), "/pa/th");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/mcconfig"
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
static void
|
||||
setup (void)
|
||||
{
|
||||
str_init_strings("KOI8-R");
|
||||
str_init_strings ("KOI8-R");
|
||||
vfs_init ();
|
||||
init_localfs ();
|
||||
}
|
||||
@ -50,8 +50,9 @@ static void
|
||||
teardown (void)
|
||||
{
|
||||
vfs_shut ();
|
||||
str_uninit_strings();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define fail_unless_strcmp( etalon ) \
|
||||
fail_unless( \
|
||||
@ -59,20 +60,22 @@ teardown (void)
|
||||
"Actial value '%s' doesn't equal to etalon '%s'", actual_value, etalon \
|
||||
)
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (create_ini_file)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
mc_config_t *mc_config;
|
||||
GError *error = NULL;
|
||||
char *actual_value;
|
||||
char *ini_filename = NULL;
|
||||
|
||||
ini_filename = g_build_filename(WORKDIR, "test-create_ini_file.ini",NULL);
|
||||
unlink(ini_filename);
|
||||
ini_filename = g_build_filename (WORKDIR, "test-create_ini_file.ini", NULL);
|
||||
unlink (ini_filename);
|
||||
|
||||
mc_config = mc_config_init (ini_filename, FALSE);
|
||||
if (mc_config == NULL)
|
||||
{
|
||||
fail("unable to create mc_congif_t object!");
|
||||
fail ("unable to create mc_congif_t object!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -81,68 +84,75 @@ START_TEST (create_ini_file)
|
||||
mc_config_set_string (mc_config, "test-group1", "test-param3", " \tsome value2\n\nf\b\005fff ");
|
||||
|
||||
mc_config_set_string_raw (mc_config, "test-group2", "test-param1", " some value ");
|
||||
mc_config_set_string_raw (mc_config, "test-group2", "test-param2", " koi8-r: Ї┼╙╘╧╫╧┼ ┌╬┴▐┼╬╔┼");
|
||||
mc_config_set_string_raw (mc_config, "test-group2", "test-param3", " \tsome value2\n\nf\b\005fff ");
|
||||
mc_config_set_string_raw (mc_config, "test-group2", "test-param2",
|
||||
" koi8-r: Ї┼╙╘╧╫╧┼ ┌╬┴▐┼╬╔┼");
|
||||
mc_config_set_string_raw (mc_config, "test-group2", "test-param3",
|
||||
" \tsome value2\n\nf\b\005fff ");
|
||||
|
||||
if (!mc_config_save_file (mc_config, &error))
|
||||
{
|
||||
fail("Unable to save config file: %s",error->message);
|
||||
g_error_free(error);
|
||||
fail ("Unable to save config file: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
mc_config_deinit (mc_config);
|
||||
mc_config = mc_config_init (ini_filename, FALSE);
|
||||
|
||||
actual_value = mc_config_get_string(mc_config, "group-not-exists", "param-not_exists", NULL);
|
||||
fail_unless(actual_value == NULL, "return value for nonexistent ini-parameters isn't NULL (default value)!");
|
||||
actual_value = mc_config_get_string (mc_config, "group-not-exists", "param-not_exists", NULL);
|
||||
fail_unless (actual_value == NULL,
|
||||
"return value for nonexistent ini-parameters isn't NULL (default value)!");
|
||||
|
||||
actual_value = mc_config_get_string(mc_config, "test-group1", "test-param1", "not-exists");
|
||||
fail_unless_strcmp(" some value ");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string (mc_config, "test-group1", "test-param1", "not-exists");
|
||||
fail_unless_strcmp (" some value ");
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string(mc_config, "test-group1", "test-param2", "not-exists");
|
||||
fail_unless_strcmp(" \tkoi8-r: Ї┼╙╘╧╫╧┼ ┌╬┴▐┼╬╔┼ ");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string (mc_config, "test-group1", "test-param2", "not-exists");
|
||||
fail_unless_strcmp (" \tkoi8-r: Ї┼╙╘╧╫╧┼ ┌╬┴▐┼╬╔┼ ");
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string(mc_config, "test-group1", "test-param3", "not-exists");
|
||||
fail_unless_strcmp(" \tsome value2\n\nf\b\005fff ");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string (mc_config, "test-group1", "test-param3", "not-exists");
|
||||
fail_unless_strcmp (" \tsome value2\n\nf\b\005fff ");
|
||||
g_free (actual_value);
|
||||
|
||||
|
||||
actual_value = mc_config_get_string_raw( mc_config, "test-group2", "test-param1", "not-exists");
|
||||
fail_unless_strcmp(" some value ");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (mc_config, "test-group2", "test-param1", "not-exists");
|
||||
fail_unless_strcmp (" some value ");
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string_raw( mc_config, "test-group2", "test-param2", "not-exists");
|
||||
fail_unless_strcmp("not-exists");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (mc_config, "test-group2", "test-param2", "not-exists");
|
||||
fail_unless_strcmp ("not-exists");
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string_raw( mc_config, "test-group2", "test-param3", "not-exists");
|
||||
fail_unless_strcmp(" \tsome value2\n\nf\b\005fff ");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (mc_config, "test-group2", "test-param3", "not-exists");
|
||||
fail_unless_strcmp (" \tsome value2\n\nf\b\005fff ");
|
||||
g_free (actual_value);
|
||||
|
||||
mc_config_deinit (mc_config);
|
||||
g_free(ini_filename);
|
||||
g_free (ini_filename);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (emulate__learn_save)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
mc_config_t *mc_config;
|
||||
char *actual_value, *esc_str;
|
||||
char *ini_filename = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
ini_filename = g_build_filename(WORKDIR, "test-emulate__learn_save.ini",NULL);
|
||||
unlink(ini_filename);
|
||||
ini_filename = g_build_filename (WORKDIR, "test-emulate__learn_save.ini", NULL);
|
||||
unlink (ini_filename);
|
||||
|
||||
mc_config = mc_config_init (ini_filename, FALSE);
|
||||
if (mc_config == NULL)
|
||||
{
|
||||
fail("unable to create mc_congif_t object!");
|
||||
fail ("unable to create mc_congif_t object!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,21 +162,23 @@ START_TEST (emulate__learn_save)
|
||||
|
||||
if (!mc_config_save_file (mc_config, &error))
|
||||
{
|
||||
fail("Unable to save config file: %s",error->message);
|
||||
g_error_free(error);
|
||||
fail ("Unable to save config file: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
mc_config_deinit (mc_config);
|
||||
mc_config = mc_config_init (ini_filename, FALSE);
|
||||
|
||||
actual_value = mc_config_get_string_raw( mc_config, "test-group1", "test-param1", "not-exists");
|
||||
fail_unless_strcmp("T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (mc_config, "test-group1", "test-param1", "not-exists");
|
||||
fail_unless_strcmp ("T\\;E\\X\\;T-FOR-\\T\\;E\\;S\\TI\\;N'G");
|
||||
g_free (actual_value);
|
||||
|
||||
mc_config_deinit (mc_config);
|
||||
g_free(ini_filename);
|
||||
g_free (ini_filename);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/mcconfig"
|
||||
#include <config.h>
|
||||
@ -40,13 +40,13 @@
|
||||
#define HOME_DIR "/home/testuser"
|
||||
|
||||
#ifdef MC_HOMEDIR_XDG
|
||||
# define CONF_MAIN HOME_DIR PATH_SEP_STR ".config"
|
||||
# define CONF_DATA HOME_DIR PATH_SEP_STR ".local" PATH_SEP_STR "share"
|
||||
# define CONF_CACHE HOME_DIR PATH_SEP_STR ".cache"
|
||||
#define CONF_MAIN HOME_DIR PATH_SEP_STR ".config"
|
||||
#define CONF_DATA HOME_DIR PATH_SEP_STR ".local" PATH_SEP_STR "share"
|
||||
#define CONF_CACHE HOME_DIR PATH_SEP_STR ".cache"
|
||||
#else
|
||||
# define CONF_MAIN HOME_DIR
|
||||
# define CONF_DATA CONF_MAIN
|
||||
# define CONF_CACHE CONF_MAIN
|
||||
#define CONF_MAIN HOME_DIR
|
||||
#define CONF_DATA CONF_MAIN
|
||||
#define CONF_CACHE CONF_MAIN
|
||||
#endif
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ setup (void)
|
||||
g_setenv ("XDG_DATA_HOME", CONF_DATA, TRUE);
|
||||
g_setenv ("XDG_CACHE_HOME", CONF_CACHE, TRUE);
|
||||
#endif
|
||||
str_init_strings("UTF-8");
|
||||
str_init_strings ("UTF-8");
|
||||
vfs_init ();
|
||||
init_localfs ();
|
||||
}
|
||||
@ -68,7 +68,7 @@ static void
|
||||
teardown (void)
|
||||
{
|
||||
vfs_shut ();
|
||||
str_uninit_strings();
|
||||
str_uninit_strings ();
|
||||
}
|
||||
|
||||
#define path_fail_unless(conf_dir, conf_name) {\
|
||||
@ -77,7 +77,9 @@ teardown (void)
|
||||
g_free (result); \
|
||||
}
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (user_configs_path_test)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *result;
|
||||
|
||||
@ -110,7 +112,9 @@ START_TEST (user_configs_path_test)
|
||||
path_fail_unless (CONF_CACHE, EDIT_BLOCK_FILE);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/util"
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/util.h"
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
setup (void)
|
||||
@ -45,6 +46,7 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const struct data_source1_struct
|
||||
{
|
||||
gboolean input_quote_percent;
|
||||
@ -56,8 +58,11 @@ static const struct data_source1_struct
|
||||
{ TRUE, "%%", "%%%%"},
|
||||
{ FALSE, "%%", "%%"},
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (quote_percent_test)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
char *actual_string;
|
||||
@ -71,10 +76,13 @@ START_TEST (quote_percent_test)
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const struct data_source2_struct
|
||||
{
|
||||
const char *input_string;
|
||||
@ -92,8 +100,11 @@ static const struct data_source2_struct
|
||||
{"~", "\\~"},
|
||||
{"blabla~", "blabla~"},
|
||||
};
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (name_quote_test)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
char *actual_string;
|
||||
@ -107,7 +118,9 @@ START_TEST (name_quote_test)
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -123,9 +136,11 @@ main (void)
|
||||
tcase_add_checked_fixture (tc_core, setup, teardown);
|
||||
|
||||
/* Add new tests here: *************** */
|
||||
tcase_add_loop_test (tc_core, quote_percent_test, 0, sizeof(data_source1)/sizeof(data_source1[0]));
|
||||
tcase_add_loop_test (tc_core, quote_percent_test, 0,
|
||||
sizeof (data_source1) / sizeof (data_source1[0]));
|
||||
|
||||
tcase_add_loop_test (tc_core, name_quote_test, 0, sizeof(data_source2)/sizeof(data_source2[0]));
|
||||
tcase_add_loop_test (tc_core, name_quote_test, 0,
|
||||
sizeof (data_source2) / sizeof (data_source2[0]));
|
||||
/* *********************************** */
|
||||
|
||||
suite_add_tcase (s, tc_core);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/search/regex"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "regex.c" /* for testing static functions*/
|
||||
#include "regex.c" /* for testing static functions */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define test_helper_valid_data(from, etalon, dest_str, replace_flags, utf) { \
|
||||
@ -41,25 +41,29 @@
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_regex_process_escape_sequence_valid)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
GString *dest_str;
|
||||
replace_transform_type_t replace_flags = REPLACE_T_NO_TRANSFORM;
|
||||
|
||||
test_helper_valid_data("{101}", "A", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("x42", "B", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("x{444}", "D", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("x{444}", "ф", dest_str, replace_flags, TRUE);
|
||||
test_helper_valid_data ("{101}", "A", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("x42", "B", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("x{444}", "D", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("x{444}", "ф", dest_str, replace_flags, TRUE);
|
||||
|
||||
test_helper_valid_data("n", "\n", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("t", "\t", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("v", "\v", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("b", "\b", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("r", "\r", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("f", "\f", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data("a", "\a", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("n", "\n", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("t", "\t", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("v", "\v", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("b", "\b", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("r", "\r", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("f", "\f", dest_str, replace_flags, FALSE);
|
||||
test_helper_valid_data ("a", "\a", dest_str, replace_flags, FALSE);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "lib/search/regex"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "regex.c" /* for testing static functions*/
|
||||
#include "regex.c" /* for testing static functions */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define test_helper_check_valid_data( a, b, c, d, e, f ) \
|
||||
@ -51,50 +51,60 @@
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_regex_replace_esc_seq_prepare_valid)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
GString *replace_str;
|
||||
gsize skip_len;
|
||||
int ret;
|
||||
|
||||
replace_str = g_string_new("bla-bla\\{123}bla-bla\\xabc234 bla-bla\\x{456abcd}bla-bla\\xtre\\n\\t\\v\\b\\r\\f\\a");
|
||||
replace_str =
|
||||
g_string_new
|
||||
("bla-bla\\{123}bla-bla\\xabc234 bla-bla\\x{456abcd}bla-bla\\xtre\\n\\t\\v\\b\\r\\f\\a");
|
||||
|
||||
test_helper_handle_esc_seq( 7, FALSE, 6, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\{123} */
|
||||
test_helper_handle_esc_seq( 20, FALSE, 4, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\xab */
|
||||
test_helper_handle_esc_seq( 36, FALSE, 11, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\x{456abcd} */
|
||||
test_helper_handle_esc_seq( 54, FALSE, 2, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\xtre */
|
||||
test_helper_handle_esc_seq( 59, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\n */
|
||||
test_helper_handle_esc_seq( 61, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\t */
|
||||
test_helper_handle_esc_seq( 63, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\v */
|
||||
test_helper_handle_esc_seq( 65, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\b */
|
||||
test_helper_handle_esc_seq( 67, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\r */
|
||||
test_helper_handle_esc_seq( 69, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\f */
|
||||
test_helper_handle_esc_seq( 71, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ ); /* \\a */
|
||||
test_helper_handle_esc_seq (7, FALSE, 6, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\{123} */
|
||||
test_helper_handle_esc_seq (20, FALSE, 4, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\xab */
|
||||
test_helper_handle_esc_seq (36, FALSE, 11, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\x{456abcd} */
|
||||
test_helper_handle_esc_seq (54, FALSE, 2, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\xtre */
|
||||
test_helper_handle_esc_seq (59, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\n */
|
||||
test_helper_handle_esc_seq (61, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\t */
|
||||
test_helper_handle_esc_seq (63, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\v */
|
||||
test_helper_handle_esc_seq (65, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\b */
|
||||
test_helper_handle_esc_seq (67, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\r */
|
||||
test_helper_handle_esc_seq (69, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\f */
|
||||
test_helper_handle_esc_seq (71, FALSE, 2, REPLACE_PREPARE_T_ESCAPE_SEQ); /* \\a */
|
||||
|
||||
g_string_free(replace_str, TRUE);
|
||||
g_string_free (replace_str, TRUE);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_regex_replace_esc_seq_prepare_invalid)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
|
||||
GString *replace_str;
|
||||
gsize skip_len;
|
||||
int ret;
|
||||
|
||||
replace_str = g_string_new("\\{123 \\x{qwerty} \\12} \\x{456a-bcd}bla-bla\\satre");
|
||||
replace_str = g_string_new ("\\{123 \\x{qwerty} \\12} \\x{456a-bcd}bla-bla\\satre");
|
||||
|
||||
test_helper_handle_esc_seq( 0, TRUE, 5, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\{123 */
|
||||
test_helper_handle_esc_seq( 6, TRUE, 3, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\x{qwerty} */
|
||||
test_helper_handle_esc_seq( 17, TRUE, 0, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\12} */
|
||||
test_helper_handle_esc_seq( 22, TRUE, 7, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\x{456a-bcd} */
|
||||
test_helper_handle_esc_seq( 41, TRUE, 0, REPLACE_PREPARE_T_NOTHING_SPECIAL ); /* \\satre */
|
||||
test_helper_handle_esc_seq (0, TRUE, 5, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\{123 */
|
||||
test_helper_handle_esc_seq (6, TRUE, 3, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\x{qwerty} */
|
||||
test_helper_handle_esc_seq (17, TRUE, 0, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\12} */
|
||||
test_helper_handle_esc_seq (22, TRUE, 7, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\x{456a-bcd} */
|
||||
test_helper_handle_esc_seq (41, TRUE, 0, REPLACE_PREPARE_T_NOTHING_SPECIAL); /* \\satre */
|
||||
|
||||
g_string_free(replace_str, TRUE);
|
||||
g_string_free (replace_str, TRUE);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
@ -62,47 +62,63 @@ teardown (void)
|
||||
} \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_serialize_deserialize_str)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *actual;
|
||||
|
||||
|
||||
actual = mc_serialize_str('s', "some test string", &error);
|
||||
actual = mc_serialize_str ('s', "some test string", &error);
|
||||
|
||||
if (actual == NULL)
|
||||
{
|
||||
fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
|
||||
g_clear_error(&error);
|
||||
fail ("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
fail_unless (strcmp(actual,"s16:some test string") == 0, "Actual value(%s) doesn't equal to etalon(s16:some test string)", actual);
|
||||
g_free(actual);
|
||||
fail_unless (strcmp (actual, "s16:some test string") == 0,
|
||||
"Actual value(%s) doesn't equal to etalon(s16:some test string)", actual);
|
||||
g_free (actual);
|
||||
|
||||
actual = mc_deserialize_str('s', NULL, &error);
|
||||
deserialize_check_incorrect( -1, "mc_serialize_str(): Input data is NULL or empty." );
|
||||
actual = mc_deserialize_str ('s', NULL, &error);
|
||||
deserialize_check_incorrect (-1, "mc_serialize_str(): Input data is NULL or empty.");
|
||||
|
||||
actual = mc_deserialize_str('s', "incorrect string", &error);
|
||||
deserialize_check_incorrect( -2, "mc_serialize_str(): String prefix doesn't equal to 's'" );
|
||||
actual = mc_deserialize_str ('s', "incorrect string", &error);
|
||||
deserialize_check_incorrect (-2, "mc_serialize_str(): String prefix doesn't equal to 's'");
|
||||
|
||||
actual = mc_deserialize_str('s', "s12345string without delimiter", &error);
|
||||
deserialize_check_incorrect( -3, "mc_serialize_str(): Length delimiter ':' doesn't exists" );
|
||||
actual = mc_deserialize_str ('s', "s12345string without delimiter", &error);
|
||||
deserialize_check_incorrect (-3, "mc_serialize_str(): Length delimiter ':' doesn't exists");
|
||||
|
||||
actual = mc_deserialize_str('s', "s1234567890123456789012345678901234567890123456789012345678901234567890:too big number", &error);
|
||||
deserialize_check_incorrect( -3, "mc_serialize_str(): Too big string length" );
|
||||
actual =
|
||||
mc_deserialize_str ('s',
|
||||
"s1234567890123456789012345678901234567890123456789012345678901234567890:too big number",
|
||||
&error);
|
||||
deserialize_check_incorrect (-3, "mc_serialize_str(): Too big string length");
|
||||
|
||||
actual = mc_deserialize_str('s', "s500:actual string length less that specified length", &error);
|
||||
deserialize_check_incorrect( -3, "mc_serialize_str(): Specified data length (500) is greater than actual data length (47)" );
|
||||
actual =
|
||||
mc_deserialize_str ('s', "s500:actual string length less that specified length", &error);
|
||||
deserialize_check_incorrect (-3,
|
||||
"mc_serialize_str(): Specified data length (500) is greater than actual data length (47)");
|
||||
|
||||
actual = mc_deserialize_str('s', "s10:actual string length great that specified length", &error);
|
||||
fail_unless (actual != NULL && strcmp(actual, "actual str") == 0, "actual (%s) doesn't equal to etalon(actual str)", actual);
|
||||
g_free(actual);
|
||||
actual =
|
||||
mc_deserialize_str ('s', "s10:actual string length great that specified length", &error);
|
||||
fail_unless (actual != NULL
|
||||
&& strcmp (actual, "actual str") == 0,
|
||||
"actual (%s) doesn't equal to etalon(actual str)", actual);
|
||||
g_free (actual);
|
||||
|
||||
actual = mc_deserialize_str('s', "s21:The right test string", &error);
|
||||
fail_unless (actual != NULL && strcmp(actual, "The right test string") == 0, "actual (%s) doesn't equal to etalon(The right test string)", actual);
|
||||
g_free(actual);
|
||||
actual = mc_deserialize_str ('s', "s21:The right test string", &error);
|
||||
fail_unless (actual != NULL
|
||||
&& strcmp (actual, "The right test string") == 0,
|
||||
"actual (%s) doesn't equal to etalon(The right test string)", actual);
|
||||
g_free (actual);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -111,7 +127,9 @@ END_TEST
|
||||
"g6:group3p6:param1v11:::bla-bla::p6:param2v31:bla-:p1:w:v2:12:g3:123:bla-bla\n" \
|
||||
"g6:group4p6:param1v5:falsep6:param2v6:654321"
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_serialize_config)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
mc_config_t *test_data;
|
||||
GError *error = NULL;
|
||||
@ -136,15 +154,19 @@ START_TEST (test_serialize_config)
|
||||
|
||||
if (actual == NULL)
|
||||
{
|
||||
fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
|
||||
g_clear_error(&error);
|
||||
fail ("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
fail_unless(strcmp(actual, etalon_str) == 0, "Not equal:\nactual (%s)\netalon (%s)", actual, etalon_str);
|
||||
g_free(actual);
|
||||
fail_unless (strcmp (actual, etalon_str) == 0, "Not equal:\nactual (%s)\netalon (%s)", actual,
|
||||
etalon_str);
|
||||
g_free (actual);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -164,72 +186,82 @@ END_TEST
|
||||
} \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_deserialize_config)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
mc_config_t *actual;
|
||||
GError *error = NULL;
|
||||
char *actual_value;
|
||||
|
||||
actual = mc_deserialize_config ("g123error in group name", &error);
|
||||
deserialize_check_incorrect( -3,
|
||||
"mc_deserialize_config() at 1: mc_serialize_str(): Length delimiter ':' doesn't exists");
|
||||
deserialize_check_incorrect (-3,
|
||||
"mc_deserialize_config() at 1: mc_serialize_str(): Length delimiter ':' doesn't exists");
|
||||
|
||||
actual = mc_deserialize_config ("p6:param1v10:some valuep6:param2v11:some value ", &error);
|
||||
deserialize_check_incorrect( -2,
|
||||
"mc_deserialize_config() at 1: mc_serialize_str(): String prefix doesn't equal to 'g'");
|
||||
deserialize_check_incorrect (-2,
|
||||
"mc_deserialize_config() at 1: mc_serialize_str(): String prefix doesn't equal to 'g'");
|
||||
|
||||
actual = mc_deserialize_config ("g6:group1v10:some valuep6:param2v11:some value ", &error);
|
||||
deserialize_check_incorrect( -2,
|
||||
"mc_deserialize_config() at 10: mc_serialize_str(): String prefix doesn't equal to 'p'");
|
||||
deserialize_check_incorrect (-2,
|
||||
"mc_deserialize_config() at 10: mc_serialize_str(): String prefix doesn't equal to 'p'");
|
||||
|
||||
actual = mc_deserialize_config ("g6:group1p6000:param2v11:some value ", &error);
|
||||
deserialize_check_incorrect( -3,
|
||||
"mc_deserialize_config() at 10: mc_serialize_str(): Specified data length (6000) is greater than actual data length (21)");
|
||||
deserialize_check_incorrect (-3,
|
||||
"mc_deserialize_config() at 10: mc_serialize_str(): Specified data length (6000) is greater than actual data length (21)");
|
||||
|
||||
actual = mc_deserialize_config (etalon_str, &error);
|
||||
|
||||
if (actual == NULL)
|
||||
{
|
||||
fail("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
|
||||
g_clear_error(&error);
|
||||
fail ("actual value is NULL!\nError code is '%d'; error message is '%s'", error->code,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
actual_value = mc_config_get_string_raw(actual, "group1", "param1", "");
|
||||
fail_unless( strcmp(actual_value, "some value") == 0,
|
||||
"group1->param1(%s) should be equal to 'some value'", actual_value);
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (actual, "group1", "param1", "");
|
||||
fail_unless (strcmp (actual_value, "some value") == 0,
|
||||
"group1->param1(%s) should be equal to 'some value'", actual_value);
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string(actual, "group1", "param2", "");
|
||||
fail_unless( strcmp(actual_value, "some value ") == 0,
|
||||
"group1->param2(%s) should be equal to 'some value '", actual_value);
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string (actual, "group1", "param2", "");
|
||||
fail_unless (strcmp (actual_value, "some value ") == 0,
|
||||
"group1->param2(%s) should be equal to 'some value '", actual_value);
|
||||
g_free (actual_value);
|
||||
|
||||
fail_unless( mc_config_get_bool(actual, "group2", "param1", FALSE) == TRUE,
|
||||
"group2->param1(FALSE) should be equal to TRUE");
|
||||
fail_unless (mc_config_get_bool (actual, "group2", "param1", FALSE) == TRUE,
|
||||
"group2->param1(FALSE) should be equal to TRUE");
|
||||
|
||||
fail_unless( mc_config_get_int(actual, "group2", "param2", 0) == 123456,
|
||||
"group2->param2(%d) should be equal to 123456", mc_config_get_int(actual, "group2", "param2", 0));
|
||||
fail_unless (mc_config_get_int (actual, "group2", "param2", 0) == 123456,
|
||||
"group2->param2(%d) should be equal to 123456", mc_config_get_int (actual,
|
||||
"group2",
|
||||
"param2", 0));
|
||||
|
||||
actual_value = mc_config_get_string_raw(actual, "group3", "param1", "");
|
||||
fail_unless( strcmp(actual_value, "::bla-bla::") == 0,
|
||||
"group3->param1(%s) should be equal to '::bla-bla::'", actual_value);
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string_raw (actual, "group3", "param1", "");
|
||||
fail_unless (strcmp (actual_value, "::bla-bla::") == 0,
|
||||
"group3->param1(%s) should be equal to '::bla-bla::'", actual_value);
|
||||
g_free (actual_value);
|
||||
|
||||
actual_value = mc_config_get_string(actual, "group3", "param2", "");
|
||||
fail_unless( strcmp(actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n") == 0,
|
||||
"group3->param2(%s) should be equal to 'bla-:p1:w:v2:12:g3:123:bla-bla\n'", actual_value);
|
||||
g_free(actual_value);
|
||||
actual_value = mc_config_get_string (actual, "group3", "param2", "");
|
||||
fail_unless (strcmp (actual_value, "bla-:p1:w:v2:12:g3:123:bla-bla\n") == 0,
|
||||
"group3->param2(%s) should be equal to 'bla-:p1:w:v2:12:g3:123:bla-bla\n'",
|
||||
actual_value);
|
||||
g_free (actual_value);
|
||||
|
||||
fail_unless( mc_config_get_bool(actual, "group4", "param1", TRUE) == FALSE,
|
||||
"group4->param1(TRUE) should be equal to FALSE");
|
||||
fail_unless (mc_config_get_bool (actual, "group4", "param1", TRUE) == FALSE,
|
||||
"group4->param1(TRUE) should be equal to FALSE");
|
||||
|
||||
fail_unless( mc_config_get_int(actual, "group4", "param2", 0) == 654321,
|
||||
"group4->param2(%d) should be equal to 654321", mc_config_get_int(actual, "group4", "param2", 0));
|
||||
fail_unless (mc_config_get_int (actual, "group4", "param2", 0) == 654321,
|
||||
"group4->param2(%d) should be equal to 654321", mc_config_get_int (actual,
|
||||
"group4",
|
||||
"param2", 0));
|
||||
|
||||
mc_config_deinit (actual);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -65,7 +65,9 @@ teardown (void)
|
||||
g_free(path); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_canonicalize_path)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
static struct vfs_s_subclass test_subclass;
|
||||
@ -95,10 +97,12 @@ START_TEST (test_canonicalize_path)
|
||||
check_canonicalize ("some_server/..", ".");
|
||||
|
||||
/* Collapse "/.." with the previous part of path */
|
||||
check_canonicalize ("/some_server/ww/some_server/../ww/../some_server/..//ww/some_server/ww", "/some_server/ww/ww/some_server/ww");
|
||||
check_canonicalize ("/some_server/ww/some_server/../ww/../some_server/..//ww/some_server/ww",
|
||||
"/some_server/ww/ww/some_server/ww");
|
||||
|
||||
/* URI style */
|
||||
check_canonicalize ("/some_server/ww/ftp://user:pass@host.net/path/", "/some_server/ww/ftp://user:pass@host.net/path");
|
||||
check_canonicalize ("/some_server/ww/ftp://user:pass@host.net/path/",
|
||||
"/some_server/ww/ftp://user:pass@host.net/path");
|
||||
|
||||
check_canonicalize ("/some_server/ww/ftp://user:pass@host.net/path/../../", "/some_server/ww");
|
||||
|
||||
@ -106,7 +110,9 @@ START_TEST (test_canonicalize_path)
|
||||
|
||||
check_canonicalize ("ftp://user/../../", "..");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -77,7 +77,9 @@ test_chdir (const vfs_path_t * vpath)
|
||||
"\n expected(%s) doesn't equal \nto actual(%s)", etalon, buffer); \
|
||||
g_free (buffer);
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (set_up_current_dir_url)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
static struct vfs_s_subclass test_subclass;
|
||||
@ -113,8 +115,9 @@ START_TEST (set_up_current_dir_url)
|
||||
cd_and_check ("..", "/");
|
||||
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -74,12 +74,14 @@ teardown (void)
|
||||
input1, input2, #etalon_condition, result); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_compare)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath1, *vpath2;
|
||||
int result;
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", ==0);
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", == 0);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
path_cmp_one_check ("/#enc:KOI8-R/тестовый/путь", "/тестовый/путь", <0);
|
||||
@ -90,7 +92,9 @@ START_TEST (test_path_compare)
|
||||
path_cmp_one_check ("/тестовый/путь", NULL, -1);
|
||||
path_cmp_one_check (NULL, NULL, -1);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#undef path_cmp_one_check
|
||||
@ -105,24 +109,28 @@ END_TEST
|
||||
input1, input2, #etalon_condition, result); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_compare_len)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath1, *vpath2;
|
||||
int result;
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", 10, ==0);
|
||||
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", 10, == 0);
|
||||
|
||||
path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 10, <0);
|
||||
|
||||
path_cmp_one_check ("/тестовый/путь", "/тест/овый/путь", 10, >0);
|
||||
|
||||
path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 9, ==0);
|
||||
path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 9, == 0);
|
||||
|
||||
path_cmp_one_check (NULL, "/тестовый/путь", 0, <0);
|
||||
path_cmp_one_check ("/тестовый/путь", NULL, 0, <0);
|
||||
path_cmp_one_check (NULL, NULL, 0, <0);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -72,18 +72,22 @@ teardown (void)
|
||||
input, etalon, result); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_length)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
size_t result;
|
||||
|
||||
path_len_one_check ("/тестовый/путь", 26);
|
||||
#ifdef HAVE_CHARSET
|
||||
path_len_one_check ("/#enc:KOI8-R/тестовый/путь", 38);
|
||||
path_len_one_check ("/#enc:KOI8-R/тестовый/путь", 38);
|
||||
#endif
|
||||
path_len_one_check (NULL, 0);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -89,56 +89,60 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_tokens_count)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
size_t tokens_count;
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str ("/");
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 0, "actual: %zu; expected: 0\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str ("/path");
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 1, "actual: %zu; expected: 1\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str ("/path1/path2/path3");
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 3, "actual: %zu; expected: 3\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str_flags ("test3://path1/path2/path3/path4", VPF_NO_CANON);
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 4, "actual: %zu; expected: 4\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str_flags ("path1/path2/path3", VPF_NO_CANON);
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 3, "actual: %zu; expected: 3\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str ("/path1/path2/path3/");
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
fail_unless (tokens_count == 3, "actual: %zu; expected: 3\n", tokens_count);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str ("/local/path/test1://user:pass@some.host:12345/bla-bla/some/path/");
|
||||
tokens_count = vfs_path_tokens_count(vpath);
|
||||
tokens_count = vfs_path_tokens_count (vpath);
|
||||
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);
|
||||
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
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -160,16 +164,18 @@ END_TEST
|
||||
vfs_path_free (vpath); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_tokens_get)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *path_tokens;
|
||||
|
||||
/* Invalid start position */
|
||||
check_invalid_token_str ("/" , 2, 1);
|
||||
check_invalid_token_str ("/", 2, 1);
|
||||
|
||||
/* Invalid negative position */
|
||||
check_invalid_token_str ("/path" , -3, 1);
|
||||
check_invalid_token_str ("/path", -3, 1);
|
||||
|
||||
/* Count of tokens is zero. Count should be autocorrected */
|
||||
check_token_str ("/path", 0, 0, "path");
|
||||
@ -182,7 +188,8 @@ START_TEST (test_vfs_path_tokens_get)
|
||||
|
||||
#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");
|
||||
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");
|
||||
@ -192,17 +199,19 @@ START_TEST (test_vfs_path_tokens_get)
|
||||
check_token_str ("test2://path1/path2/path3/path4", 1, 2, "test2://path2/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 throught non-LOCAL VFS */
|
||||
check_token_str ("/path1/path2/test1://user:pass@some.host:12345/path3/path4", 1, 2, "path2/test1://user:pass@some.host:12345/path3");
|
||||
check_token_str ("/path1/path2/test1://user:pass@some.host:12345/path3/path4", 1, 2,
|
||||
"path2/test1://user:pass@some.host:12345/path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 from LOCAL VFS */
|
||||
/* TODO: currently this test don't passed. Probably broken string URI parser */
|
||||
/* check_token_str ("test3://path1/path2/test2://test3://path3/path4", 1, 2, "path2/path3"); */
|
||||
/* check_token_str ("test3://path1/path2/test2://test3://path3/path4", 1, 2, "path2/path3"); */
|
||||
|
||||
/* get 'path2/path3' by 1,2 where path2 it's LOCAL VFS */
|
||||
check_token_str ("test3://path1/path2/test2://path3/path4", 1, 2, "path2/test2://path3");
|
||||
|
||||
/* get 'path2/path3' by 1,2 where path3 it's LOCAL VFS */
|
||||
check_token_str ("test2://path1/path2/test3://path3/path4", 1, 2, "test2://path2/test3://path3");
|
||||
check_token_str ("test2://path1/path2/test3://path3/path4", 1, 2,
|
||||
"test2://path2/test3://path3");
|
||||
|
||||
/* get 'path4' by -1,1 */
|
||||
check_token_str ("/path1/path2/path3/path4", -1, 1, "path4");
|
||||
@ -211,71 +220,87 @@ START_TEST (test_vfs_path_tokens_get)
|
||||
check_token_str ("/path1/path2/path3/path4", -3, 0, "path2/path3/path4");
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_append_vpath)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
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");
|
||||
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");
|
||||
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/");
|
||||
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);
|
||||
|
||||
fail_unless (vfs_path_elements_count(vpath3) == 6,
|
||||
"\nvpath elements count should be %d, actial is %d\n",
|
||||
6,
|
||||
vfs_path_elements_count(vpath3)
|
||||
);
|
||||
fail_unless (vfs_path_elements_count (vpath3) == 6,
|
||||
"\nvpath elements count should be %d, actial is %d\n",
|
||||
6, vfs_path_elements_count (vpath3));
|
||||
vfs_path_free (vpath1);
|
||||
vfs_path_free (vpath2);
|
||||
vfs_path_free (vpath3);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_relative)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath, *copy_vpath;
|
||||
char *path_str;
|
||||
|
||||
vpath = vfs_path_from_str_flags("../bla-bla", VPF_NO_CANON);
|
||||
vpath = vfs_path_from_str_flags ("../bla-bla", VPF_NO_CANON);
|
||||
fail_unless (vpath->relative, "relative flag fail!\n");
|
||||
|
||||
path_str = vfs_path_to_str (vpath);
|
||||
|
||||
fail_unless (strcmp(path_str, "../bla-bla") == 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
fail_unless (strcmp (path_str, "../bla-bla") == 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
g_free (path_str);
|
||||
|
||||
path_str = (char *) vfs_path_get_last_path_str (vpath);
|
||||
fail_unless (strcmp(path_str, "../bla-bla") == 0, "relative fail!\nactual: element->path=[%s]\n", path_str);
|
||||
fail_unless (strcmp (path_str, "../bla-bla") == 0,
|
||||
"relative fail!\nactual: element->path=[%s]\n", path_str);
|
||||
|
||||
copy_vpath = vfs_path_clone (vpath);
|
||||
|
||||
path_str = vfs_path_to_str (copy_vpath);
|
||||
|
||||
fail_unless (strcmp(path_str, "../bla-bla") == 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
fail_unless (strcmp (path_str, "../bla-bla") == 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
g_free (path_str);
|
||||
|
||||
vfs_path_free (copy_vpath);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str_flags ("../path/test1://user:pass@some.host:12345/bla-bla/some/path/", VPF_NO_CANON);
|
||||
vpath =
|
||||
vfs_path_from_str_flags ("../path/test1://user:pass@some.host:12345/bla-bla/some/path/",
|
||||
VPF_NO_CANON);
|
||||
path_str = vfs_path_to_str (vpath);
|
||||
fail_unless (strcmp(path_str, "../path/test1://user:pass@some.host:12345/bla-bla/some/path/") == 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
fail_unless (strcmp (path_str, "../path/test1://user:pass@some.host:12345/bla-bla/some/path/")
|
||||
== 0, "relative fail!\nactual: [%s]\n", path_str);
|
||||
g_free (path_str);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -60,7 +60,8 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void test_init_vfs(const char *encoding)
|
||||
static void
|
||||
test_init_vfs (const char *encoding)
|
||||
{
|
||||
str_init_strings (encoding);
|
||||
|
||||
@ -76,7 +77,8 @@ static void test_init_vfs(const char *encoding)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void test_deinit_vfs()
|
||||
static void
|
||||
test_deinit_vfs ()
|
||||
{
|
||||
free_codepages_list ();
|
||||
str_uninit_strings ();
|
||||
@ -95,51 +97,64 @@ static void test_deinit_vfs()
|
||||
vfs_path_free (vpath);\
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_recode_base_utf8)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
const vfs_path_element_t *element;
|
||||
|
||||
test_init_vfs("UTF-8");
|
||||
test_init_vfs ("UTF-8");
|
||||
|
||||
path_recode_one_check("/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╘┼╙╘╧╫┘╩/╨╒╘╪");
|
||||
path_recode_one_check ("/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╘┼╙╘╧╫┘╩/╨╒╘╪");
|
||||
|
||||
path_recode_one_check("/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/╘┼╙╘╧╫┘╩/╨╒╘╪", "/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
path_recode_one_check ("/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/╘┼╙╘╧╫┘╩/╨╒╘╪",
|
||||
"/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
|
||||
test_deinit_vfs();
|
||||
test_deinit_vfs ();
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_recode_base_koi8r)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
const vfs_path_element_t *element;
|
||||
|
||||
test_init_vfs("KOI8-R");
|
||||
test_init_vfs ("KOI8-R");
|
||||
|
||||
path_recode_one_check("/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
path_recode_one_check ("/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М",
|
||||
"/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
|
||||
path_recode_one_check("/#enc:UTF-8/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", "/#enc:UTF-8/╘┼╙╘╧╫┘╩/╨╒╘╪");
|
||||
path_recode_one_check ("/#enc:UTF-8/╘┼╙╘╧╫┘╩/╨╒╘╪", "/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М",
|
||||
"/#enc:UTF-8/╘┼╙╘╧╫┘╩/╨╒╘╪");
|
||||
|
||||
test_deinit_vfs();
|
||||
test_deinit_vfs ();
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
struct vfs_s_subclass test_subclass1;
|
||||
struct vfs_class vfs_test_ops1;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST(test_path_to_str_flags)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
|
||||
vfs_path_t *vpath;
|
||||
char *str_path;
|
||||
|
||||
test_init_vfs("UTF-8");
|
||||
test_init_vfs ("UTF-8");
|
||||
|
||||
test_subclass1.flags = VFS_S_REMOTE;
|
||||
vfs_s_init_class (&vfs_test_ops1, &test_subclass1);
|
||||
@ -154,17 +169,21 @@ START_TEST(test_path_to_str_flags)
|
||||
g_free (str_path);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str ("/test1://user:passwd@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
vpath =
|
||||
vfs_path_from_str ("/test1://user:passwd@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М");
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_PASSWORD);
|
||||
fail_unless (strcmp ("/test1://user@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("/test1://user@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path)
|
||||
== 0, "\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_RECODE);
|
||||
fail_unless (strcmp ("/test1://user:passwd@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("/test1://user:passwd@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0,
|
||||
"\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_RECODE | VPF_STRIP_PASSWORD);
|
||||
fail_unless (strcmp ("/test1://user@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("/test1://user@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n",
|
||||
str_path);
|
||||
g_free (str_path);
|
||||
|
||||
vfs_path_free (vpath);
|
||||
@ -175,34 +194,46 @@ START_TEST(test_path_to_str_flags)
|
||||
g_free (str_path);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_build_filename (mc_config_get_home_dir (), "test1://user:passwd@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", NULL);
|
||||
vpath =
|
||||
vfs_path_build_filename (mc_config_get_home_dir (),
|
||||
"test1://user:passwd@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М",
|
||||
NULL);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/#enc:KOI8-R/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path)
|
||||
== 0, "\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
str_path =
|
||||
vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/╤В╨╡╤Б╤В╨╛╨▓╤Л╨╣/╨┐╤Г╤В╤М", str_path) == 0,
|
||||
"\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_RECODE);
|
||||
fail_unless (strcmp ("~/test1://user:passwd@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("~/test1://user:passwd@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0,
|
||||
"\nstr=%s\n", str_path);
|
||||
g_free (str_path);
|
||||
str_path = vfs_path_to_str_flags (vpath, 0, VPF_STRIP_HOME | VPF_RECODE | VPF_STRIP_PASSWORD);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n", str_path);
|
||||
fail_unless (strcmp ("~/test1://user@host.name/╘┼╙╘╧╫┘╩/╨╒╘╪", str_path) == 0, "\nstr=%s\n",
|
||||
str_path);
|
||||
g_free (str_path);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
test_deinit_vfs();
|
||||
test_deinit_vfs ();
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST(test_encode_info_at_start)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *actual;
|
||||
const vfs_path_element_t *vpath_element;
|
||||
|
||||
test_init_vfs("UTF-8");
|
||||
test_init_vfs ("UTF-8");
|
||||
|
||||
vpath = vfs_path_from_str ("#enc:KOI8-R/bla-bla/some/path");
|
||||
actual = vfs_path_to_str (vpath);
|
||||
@ -211,14 +242,17 @@ START_TEST(test_encode_info_at_start)
|
||||
|
||||
vpath_element = vfs_path_get_by_index (vpath, -1);
|
||||
|
||||
fail_unless (strcmp ("/bla-bla/some/path", vpath_element->path) == 0, "\nvpath_element->path=%s\n", vpath_element->path);
|
||||
fail_unless (strcmp ("/bla-bla/some/path", vpath_element->path) == 0,
|
||||
"\nvpath_element->path=%s\n", vpath_element->path);
|
||||
|
||||
g_free (actual);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
test_deinit_vfs();
|
||||
test_deinit_vfs ();
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -141,7 +141,9 @@ teardown (void)
|
||||
"p10:vfs_prefixv5:test3"
|
||||
#endif
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_path_serialize_deserialize)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *serialized_vpath;
|
||||
@ -153,36 +155,38 @@ START_TEST (test_path_serialize_deserialize)
|
||||
|
||||
if (serialized_vpath == NULL)
|
||||
{
|
||||
fail ("serialized_vpath is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
|
||||
fail ("serialized_vpath is NULL!\nError code is '%d'; error message is '%s'", error->code,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
fail_unless (
|
||||
strcmp (serialized_vpath, ETALON_SERIALIZED_PATH ) == 0,
|
||||
"\nserialized_vpath (%s)\nnot equal to etalon (%s)", serialized_vpath, ETALON_SERIALIZED_PATH
|
||||
);
|
||||
fail_unless (strcmp (serialized_vpath, ETALON_SERIALIZED_PATH) == 0,
|
||||
"\nserialized_vpath (%s)\nnot equal to etalon (%s)", serialized_vpath,
|
||||
ETALON_SERIALIZED_PATH);
|
||||
|
||||
vpath = vfs_path_deserialize (serialized_vpath, &error);
|
||||
g_free (serialized_vpath);
|
||||
|
||||
if (vpath == NULL)
|
||||
{
|
||||
fail ("vpath is NULL!\nError code is '%d'; error message is '%s'", error->code, error->message);
|
||||
fail ("vpath is NULL!\nError code is '%d'; error message is '%s'", error->code,
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
serialized_vpath = vfs_path_to_str (vpath);
|
||||
fail_unless (
|
||||
strcmp (serialized_vpath, ETALON_PATH_URL_STR) == 0,
|
||||
"\ndeserialized path (%s)\nnot equal to etalon (%s)", serialized_vpath, ETALON_PATH_URL_STR
|
||||
);
|
||||
vfs_path_free(vpath);
|
||||
g_free(serialized_vpath);
|
||||
fail_unless (strcmp (serialized_vpath, ETALON_PATH_URL_STR) == 0,
|
||||
"\ndeserialized path (%s)\nnot equal to etalon (%s)", serialized_vpath,
|
||||
ETALON_PATH_URL_STR);
|
||||
vfs_path_free (vpath);
|
||||
g_free (serialized_vpath);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
Written by:
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
Slava Zanko <slavazanko@gmail.com>, 2011
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -81,25 +81,31 @@ test_chdir (const vfs_path_t * vpath)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_relative_cd)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
|
||||
vpath = vfs_path_from_str ("/test1://user:pass@some.host:12345/path/to/dir");
|
||||
fail_if (mc_chdir(vpath) == -1);
|
||||
fail_if (mc_chdir (vpath) == -1);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
vpath = vfs_path_from_str_flags ("some-non-exists-dir", VPF_NO_CANON);
|
||||
fail_if (mc_chdir(vpath) == -1);
|
||||
fail_if (mc_chdir (vpath) == -1);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Relative to panel_correct_path_to_show() */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vpath_to_str_filter)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath, *last_vpath;
|
||||
char *filtered_path;
|
||||
@ -115,14 +121,16 @@ START_TEST (test_vpath_to_str_filter)
|
||||
vfs_path_add_element (last_vpath, path_element);
|
||||
|
||||
filtered_path = vfs_path_to_str_flags (last_vpath, 0,
|
||||
VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
VPF_STRIP_HOME | VPF_STRIP_PASSWORD | VPF_HIDE_CHARSET);
|
||||
vfs_path_free (last_vpath);
|
||||
|
||||
fail_unless (strcmp("test1://some.host/dir", filtered_path) == 0, "actual: %s", filtered_path);
|
||||
fail_unless (strcmp ("test1://some.host/dir", filtered_path) == 0, "actual: %s", filtered_path);
|
||||
g_free (filtered_path);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -65,26 +65,30 @@ teardown (void)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_mc_tmpdir)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
const char *tmpdir;
|
||||
const char *env_tmpdir;
|
||||
|
||||
tmpdir = mc_tmpdir();
|
||||
fail_unless (
|
||||
g_file_test (tmpdir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR),
|
||||
"\nNo such directory: %s\n", tmpdir
|
||||
);
|
||||
tmpdir = mc_tmpdir ();
|
||||
fail_unless (g_file_test (tmpdir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR),
|
||||
"\nNo such directory: %s\n", tmpdir);
|
||||
|
||||
env_tmpdir = g_getenv ("MC_TMPDIR");
|
||||
fail_unless (
|
||||
strcmp (env_tmpdir, tmpdir) == 0,
|
||||
"\nenv_tmpdir=%s\n tmpdir=%s\n", env_tmpdir, tmpdir
|
||||
);
|
||||
fail_unless (strcmp (env_tmpdir, tmpdir) == 0,
|
||||
"\nenv_tmpdir=%s\n tmpdir=%s\n", env_tmpdir, tmpdir);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_mc_mkstemps)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *pname_vpath = NULL;
|
||||
char *pname;
|
||||
@ -100,20 +104,18 @@ START_TEST (test_mc_mkstemps)
|
||||
vfs_path_free (pname_vpath);
|
||||
close (fd);
|
||||
|
||||
fail_unless (
|
||||
g_file_test (pname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
||||
"\nNo such file: %s\n", pname
|
||||
);
|
||||
unlink(pname);
|
||||
fail_unless (g_file_test (pname, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR),
|
||||
"\nNo such file: %s\n", pname);
|
||||
unlink (pname);
|
||||
|
||||
begin_pname = g_build_filename (mc_tmpdir(), "mctest-", NULL);
|
||||
fail_unless (
|
||||
strncmp(pname, begin_pname, strlen(begin_pname)) == 0,
|
||||
"\nstart of %s should be equal to %s\n", pname, begin_pname
|
||||
);
|
||||
begin_pname = g_build_filename (mc_tmpdir (), "mctest-", NULL);
|
||||
fail_unless (strncmp (pname, begin_pname, strlen (begin_pname)) == 0,
|
||||
"\nstart of %s should be equal to %s\n", pname, begin_pname);
|
||||
g_free (pname);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -94,8 +94,8 @@ message (int flags, const char *title, const char *text, ...)
|
||||
va_start (ap, text);
|
||||
p = g_strdup_vprintf (text, ap);
|
||||
va_end (ap);
|
||||
printf("message(): %s\n", p);
|
||||
g_free(p);
|
||||
printf ("message(): %s\n", p);
|
||||
g_free (p);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -127,8 +127,10 @@ message (int flags, const char *title, const char *text, ...)
|
||||
*/\
|
||||
}
|
||||
|
||||
static void check_vfs_parse_ls_lga_call(const char *input_data, int etalon_result,
|
||||
const char *etalon_filename, const char *etalon_linkname, struct stat etalon_stat, size_t *filepos)
|
||||
static void
|
||||
check_vfs_parse_ls_lga_call (const char *input_data, int etalon_result,
|
||||
const char *etalon_filename, const char *etalon_linkname,
|
||||
struct stat etalon_stat, size_t * filepos)
|
||||
{
|
||||
static struct stat test_stat;
|
||||
char *filename = NULL;
|
||||
@ -138,20 +140,25 @@ const char *etalon_filename, const char *etalon_linkname, struct stat etalon_sta
|
||||
result = vfs_parse_ls_lga (input_data, &test_stat, &filename, &linkname, filepos);
|
||||
|
||||
fail_if (result != etalon_result,
|
||||
"\nactual result: %d\netalon result: %d\n", result, etalon_result);
|
||||
"\nactual result: %d\netalon result: %d\n", result, etalon_result);
|
||||
|
||||
fail_unless((filename != NULL && etalon_filename != NULL && strcmp(filename, etalon_filename) == 0)
|
||||
|| (filename == NULL && etalon_filename == filename),
|
||||
"\nactual filename '%s'\netalon filename '%s'", filename, etalon_filename);
|
||||
fail_unless ((filename != NULL && etalon_filename != NULL
|
||||
&& strcmp (filename, etalon_filename) == 0) || (filename == NULL
|
||||
&& etalon_filename == filename),
|
||||
"\nactual filename '%s'\netalon filename '%s'", filename, etalon_filename);
|
||||
|
||||
fail_unless((linkname != NULL && etalon_linkname != NULL && strcmp(linkname, etalon_linkname) == 0)
|
||||
|| (linkname == NULL && etalon_linkname == linkname),
|
||||
"\nactual linkname '%s'\netalon linkname '%s'", linkname, etalon_linkname);
|
||||
fail_unless ((linkname != NULL && etalon_linkname != NULL
|
||||
&& strcmp (linkname, etalon_linkname) == 0) || (linkname == NULL
|
||||
&& etalon_linkname == linkname),
|
||||
"\nactual linkname '%s'\netalon linkname '%s'", linkname, etalon_linkname);
|
||||
|
||||
check_stat_struct(etalon_stat, test_stat, input_data);
|
||||
check_stat_struct (etalon_stat, test_stat, input_data);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_parse_ls_lga)
|
||||
/* *INDENT-ON* */
|
||||
|
||||
{
|
||||
size_t filepos = 0;
|
||||
|
||||
@ -171,13 +178,11 @@ START_TEST (test_vfs_parse_ls_lga)
|
||||
etalon_stat.st_mtime = 1308838140;
|
||||
etalon_stat.st_ctime = 1308838140;
|
||||
|
||||
vfs_parse_ls_lga_init();
|
||||
vfs_parse_ls_lga_init ();
|
||||
|
||||
check_vfs_parse_ls_lga_call(
|
||||
"drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root",
|
||||
1, "build_root", NULL, etalon_stat,
|
||||
NULL
|
||||
);
|
||||
check_vfs_parse_ls_lga_call
|
||||
("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root", 1, "build_root",
|
||||
NULL, etalon_stat, NULL);
|
||||
|
||||
etalon_stat.st_dev = 0;
|
||||
etalon_stat.st_ino = 0;
|
||||
@ -193,11 +198,9 @@ START_TEST (test_vfs_parse_ls_lga)
|
||||
etalon_stat.st_mtime = 1268431200;
|
||||
etalon_stat.st_ctime = 1268431200;
|
||||
|
||||
check_vfs_parse_ls_lga_call(
|
||||
"lrwxrwxrwx 1 500 500 11 Mar 13 2010 COPYING -> doc/COPYING",
|
||||
1, "COPYING", "doc/COPYING", etalon_stat,
|
||||
NULL
|
||||
);
|
||||
check_vfs_parse_ls_lga_call
|
||||
("lrwxrwxrwx 1 500 500 11 Mar 13 2010 COPYING -> doc/COPYING", 1,
|
||||
"COPYING", "doc/COPYING", etalon_stat, NULL);
|
||||
|
||||
etalon_stat.st_dev = 0;
|
||||
etalon_stat.st_ino = 0;
|
||||
@ -213,11 +216,8 @@ START_TEST (test_vfs_parse_ls_lga)
|
||||
etalon_stat.st_mtime = 1308838140;
|
||||
etalon_stat.st_ctime = 1308838140;
|
||||
|
||||
check_vfs_parse_ls_lga_call(
|
||||
"drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..",
|
||||
1, "..", NULL, etalon_stat,
|
||||
&filepos
|
||||
);
|
||||
check_vfs_parse_ls_lga_call ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..",
|
||||
1, "..", NULL, etalon_stat, &filepos);
|
||||
|
||||
|
||||
etalon_stat.st_dev = 0;
|
||||
@ -234,27 +234,30 @@ START_TEST (test_vfs_parse_ls_lga)
|
||||
etalon_stat.st_mtime = 1308838140;
|
||||
etalon_stat.st_ctime = 1308838140;
|
||||
|
||||
check_vfs_parse_ls_lga_call(
|
||||
"drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root",
|
||||
1, "build_root", NULL, etalon_stat,
|
||||
&filepos
|
||||
);
|
||||
check_vfs_parse_ls_lga_call
|
||||
("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root", 1, "build_root",
|
||||
NULL, etalon_stat, &filepos);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_parse_ls_lga_reorder)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
size_t filepos = 0;
|
||||
struct vfs_s_entry *ent1, *ent2, *ent3;
|
||||
|
||||
vfs_parse_ls_lga_init();
|
||||
vfs_parse_ls_lga_init ();
|
||||
|
||||
ent1 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0);
|
||||
if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1",
|
||||
&ent1->ino->st, &ent1->name, &ent1->ino->linkname, &filepos))
|
||||
if (!vfs_parse_ls_lga
|
||||
("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1", &ent1->ino->st,
|
||||
&ent1->name, &ent1->ino->linkname, &filepos))
|
||||
{
|
||||
fail ("An error occured while parse ls output");
|
||||
return;
|
||||
@ -264,8 +267,8 @@ START_TEST (test_vfs_parse_ls_lga_reorder)
|
||||
|
||||
|
||||
ent2 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0);
|
||||
if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2",
|
||||
&ent2->ino->st, &ent2->name, &ent2->ino->linkname, &filepos))
|
||||
if (!vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2",
|
||||
&ent2->ino->st, &ent2->name, &ent2->ino->linkname, &filepos))
|
||||
{
|
||||
fail ("An error occured while parse ls output");
|
||||
return;
|
||||
@ -274,8 +277,8 @@ START_TEST (test_vfs_parse_ls_lga_reorder)
|
||||
vfs_s_insert_entry (&vfs_test_ops1, vfs_root_inode, ent2);
|
||||
|
||||
ent3 = vfs_s_generate_entry (&vfs_test_ops1, NULL, vfs_root_inode, 0);
|
||||
if (! vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..",
|
||||
&ent3->ino->st, &ent3->name, &ent3->ino->linkname, &filepos))
|
||||
if (!vfs_parse_ls_lga ("drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..",
|
||||
&ent3->ino->st, &ent3->name, &ent3->ino->linkname, &filepos))
|
||||
{
|
||||
fail ("An error occured while parse ls output");
|
||||
return;
|
||||
@ -285,10 +288,14 @@ START_TEST (test_vfs_parse_ls_lga_reorder)
|
||||
|
||||
vfs_s_normalize_filename_leading_spaces (vfs_root_inode, vfs_parse_ls_lga_get_final_spaces ());
|
||||
|
||||
fail_unless(strcmp(ent1->name, " build_root1") == 0, "\nactual '%s'\nnot equal to '%s'\n", ent1->name, " build_root1");
|
||||
fail_unless(strcmp(ent2->name, " build_root2") == 0, "\nactual '%s'\nnot equal to '%s'\n", ent2->name, " build_root2");
|
||||
fail_unless (strcmp (ent1->name, " build_root1") == 0, "\nactual '%s'\nnot equal to '%s'\n",
|
||||
ent1->name, " build_root1");
|
||||
fail_unless (strcmp (ent2->name, " build_root2") == 0, "\nactual '%s'\nnot equal to '%s'\n",
|
||||
ent2->name, " build_root2");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define parce_one_line(ent_index, ls_output) {\
|
||||
@ -310,26 +317,31 @@ END_TEST
|
||||
);\
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_parse_ls_lga_unaligned)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
size_t filepos = 0;
|
||||
struct vfs_s_entry *ent[4];
|
||||
|
||||
vfs_parse_ls_lga_init();
|
||||
vfs_parse_ls_lga_init ();
|
||||
|
||||
parce_one_line(0, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1");
|
||||
parce_one_line(1, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2");
|
||||
parce_one_line(2, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..");
|
||||
parce_one_line(3, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root 0");
|
||||
parce_one_line (0, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root1");
|
||||
parce_one_line (1, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root2");
|
||||
parce_one_line (2, "drwxrwxr-x 10 500 500 4096 Jun 23 17:09 ..");
|
||||
parce_one_line (3,
|
||||
"drwxrwxr-x 10 500 500 4096 Jun 23 17:09 build_root 0");
|
||||
|
||||
vfs_s_normalize_filename_leading_spaces (vfs_root_inode, vfs_parse_ls_lga_get_final_spaces ());
|
||||
|
||||
fail_unless_ent(0, "build_root1");
|
||||
fail_unless_ent(1, " build_root2");
|
||||
fail_unless_ent(3, " build_root 0");
|
||||
fail_unless_ent (0, "build_root1");
|
||||
fail_unless_ent (1, " build_root2");
|
||||
fail_unless_ent (3, " build_root 0");
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/path.c" /* for testing static methods */
|
||||
#include "lib/vfs/path.c" /* for testing static methods */
|
||||
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
@ -85,7 +85,9 @@ teardown (void)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define ETALON_PATH_STR "/#test1/bla-bla/some/path/#test2/bla-bla/some/path#test3/111/22/33"
|
||||
#define ETALON_PATH_URL_STR "/test1://bla-bla/some/path/test2://bla-bla/some/path/test3://111/22/33"
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_from_to_string)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
size_t vpath_len;
|
||||
@ -93,20 +95,25 @@ START_TEST (test_vfs_path_from_to_string)
|
||||
vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER);
|
||||
|
||||
|
||||
vpath_len = vfs_path_elements_count(vpath);
|
||||
fail_unless(vpath_len == 4, "vpath length should be 4 (actial: %d)",vpath_len);
|
||||
vpath_len = vfs_path_elements_count (vpath);
|
||||
fail_unless (vpath_len == 4, "vpath length should be 4 (actial: %d)", vpath_len);
|
||||
|
||||
result = vfs_path_to_str(vpath);
|
||||
fail_unless(strcmp(ETALON_PATH_URL_STR, result) == 0, "expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str (vpath);
|
||||
fail_unless (strcmp (ETALON_PATH_URL_STR, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free (result);
|
||||
|
||||
vfs_path_free(vpath);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_from_to_string2)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
size_t vpath_len;
|
||||
@ -115,89 +122,91 @@ START_TEST (test_vfs_path_from_to_string2)
|
||||
|
||||
vpath = vfs_path_from_str ("/");
|
||||
|
||||
vpath_len = vfs_path_elements_count(vpath);
|
||||
fail_unless(vpath_len == 1, "vpath length should be 1 (actial: %d)",vpath_len);
|
||||
vpath_len = vfs_path_elements_count (vpath);
|
||||
fail_unless (vpath_len == 1, "vpath length should be 1 (actial: %d)", vpath_len);
|
||||
|
||||
result = vfs_path_to_str(vpath);
|
||||
fail_unless(strcmp("/", result) == 0, "expected(%s) doesn't equal to actual(%s)", "/", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str (vpath);
|
||||
fail_unless (strcmp ("/", result) == 0, "expected(%s) doesn't equal to actual(%s)", "/",
|
||||
result);
|
||||
g_free (result);
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
fail_unless(strcmp("/", path_element->path) == 0, "expected(%s) doesn't equal to actual(%s)", "/", path_element->path);
|
||||
fail_unless (strcmp ("/", path_element->path) == 0, "expected(%s) doesn't equal to actual(%s)",
|
||||
"/", path_element->path);
|
||||
|
||||
fail_unless(path_element->class == &vfs_local_ops , "actual vfs-class doesn't equal to localfs");
|
||||
fail_unless (path_element->class == &vfs_local_ops,
|
||||
"actual vfs-class doesn't equal to localfs");
|
||||
|
||||
vfs_path_free(vpath);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_from_to_partial_string_by_class)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER);
|
||||
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, -1);
|
||||
fail_unless(
|
||||
strcmp("/test1://bla-bla/some/path/test2://bla-bla/some/path", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/test2://bla-bla/some/path", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, -1);
|
||||
fail_unless (strcmp ("/test1://bla-bla/some/path/test2://bla-bla/some/path", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)",
|
||||
"/test1://bla-bla/some/path/test2://bla-bla/some/path", result);
|
||||
g_free (result);
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, -2);
|
||||
fail_unless(
|
||||
strcmp("/test1://bla-bla/some/path/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, -2);
|
||||
fail_unless (strcmp ("/test1://bla-bla/some/path/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/", result);
|
||||
g_free (result);
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, -3);
|
||||
fail_unless(
|
||||
strcmp("/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, -3);
|
||||
fail_unless (strcmp ("/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/", result);
|
||||
g_free (result);
|
||||
|
||||
/* index out of bound*/
|
||||
result = vfs_path_to_str_elements_count(vpath, -4);
|
||||
fail_unless(
|
||||
strcmp("", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "", result);
|
||||
g_free(result);
|
||||
/* index out of bound */
|
||||
result = vfs_path_to_str_elements_count (vpath, -4);
|
||||
fail_unless (strcmp ("", result) == 0, "expected(%s) doesn't equal to actual(%s)", "", result);
|
||||
g_free (result);
|
||||
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, 1);
|
||||
fail_unless(
|
||||
strcmp("/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, 1);
|
||||
fail_unless (strcmp ("/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/", result);
|
||||
g_free (result);
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, 2);
|
||||
fail_unless(
|
||||
strcmp("/test1://bla-bla/some/path/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, 2);
|
||||
fail_unless (strcmp ("/test1://bla-bla/some/path/", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/", result);
|
||||
g_free (result);
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, 3);
|
||||
fail_unless(
|
||||
strcmp("/test1://bla-bla/some/path/test2://bla-bla/some/path", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/test1://bla-bla/some/path/test2://bla-bla/some/path", result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, 3);
|
||||
fail_unless (strcmp ("/test1://bla-bla/some/path/test2://bla-bla/some/path", result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)",
|
||||
"/test1://bla-bla/some/path/test2://bla-bla/some/path", result);
|
||||
g_free (result);
|
||||
|
||||
result = vfs_path_to_str_elements_count(vpath, 4);
|
||||
fail_unless(
|
||||
strcmp(ETALON_PATH_URL_STR, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str_elements_count (vpath, 4);
|
||||
fail_unless (strcmp (ETALON_PATH_URL_STR, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free (result);
|
||||
|
||||
/* index out of bound*/
|
||||
result = vfs_path_to_str_elements_count(vpath, 5);
|
||||
fail_unless(
|
||||
strcmp(ETALON_PATH_URL_STR, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free(result);
|
||||
/* index out of bound */
|
||||
result = vfs_path_to_str_elements_count (vpath, 5);
|
||||
fail_unless (strcmp (ETALON_PATH_URL_STR, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH_URL_STR, result);
|
||||
g_free (result);
|
||||
|
||||
vfs_path_free(vpath);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#ifdef HAVE_CHARSET
|
||||
#define encoding_check( input , etalon ) \
|
||||
@ -214,48 +223,49 @@ END_TEST
|
||||
vfs_path_free(vpath); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_from_to_string_encoding)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
load_codepages_list ();
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/#enc:IBM866/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://#enc:IBM866/bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/#enc:IBM866/some/path/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://#enc:IBM866/bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/some/#enc:KOI8-R/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/some/path/#test2/bla-bla2/#enc:IBM866/some/#enc:KOI8-R/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/some/path/#test2/#enc:IBM866/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/some/path/#test2/#enc:IBM866/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
encoding_check (
|
||||
"/#test1/bla-bla1/some/path/#enc:IBM866/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://#enc:IBM866/bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33"
|
||||
);
|
||||
encoding_check
|
||||
("/#test1/bla-bla1/some/path/#enc:IBM866/#test2/bla-bla2/#enc:KOI8-R/some/path#test3/111/22/33",
|
||||
"/test1://#enc:IBM866/bla-bla1/some/path/test2://#enc:KOI8-R/bla-bla2/some/path/test3://111/22/33");
|
||||
|
||||
free_codepages_list ();
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define ETALON_STR "/path/to/file.ext/test1://#enc:KOI8-R"
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_encoding_at_end)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
char *result;
|
||||
@ -264,46 +274,57 @@ START_TEST (test_vfs_path_encoding_at_end)
|
||||
mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR;
|
||||
load_codepages_list ();
|
||||
|
||||
vpath = vfs_path_from_str_flags ("/path/to/file.ext#test1:/#enc:KOI8-R", VPF_USE_DEPRECATED_PARSER);
|
||||
result = vfs_path_to_str(vpath);
|
||||
vpath =
|
||||
vfs_path_from_str_flags ("/path/to/file.ext#test1:/#enc:KOI8-R", VPF_USE_DEPRECATED_PARSER);
|
||||
result = vfs_path_to_str (vpath);
|
||||
|
||||
element = vfs_path_get_by_index(vpath, -1);
|
||||
fail_unless(*element->path == '\0', "element->path should be empty, but actual value is '%s'",element->path);
|
||||
fail_unless(element->encoding != NULL && strcmp(element->encoding, "KOI8-R") == 0,
|
||||
"element->encoding should be 'KOI8-R', but actual value is '%s'",element->encoding);
|
||||
element = vfs_path_get_by_index (vpath, -1);
|
||||
fail_unless (*element->path == '\0', "element->path should be empty, but actual value is '%s'",
|
||||
element->path);
|
||||
fail_unless (element->encoding != NULL
|
||||
&& strcmp (element->encoding, "KOI8-R") == 0,
|
||||
"element->encoding should be 'KOI8-R', but actual value is '%s'",
|
||||
element->encoding);
|
||||
|
||||
fail_unless( result != NULL && strcmp(result, ETALON_STR) ==0,
|
||||
"\nactual: %s\netalon: %s", result , ETALON_STR );
|
||||
fail_unless (result != NULL && strcmp (result, ETALON_STR) == 0,
|
||||
"\nactual: %s\netalon: %s", result, ETALON_STR);
|
||||
|
||||
g_free(result);
|
||||
vfs_path_free(vpath);
|
||||
g_free (result);
|
||||
vfs_path_free (vpath);
|
||||
|
||||
free_codepages_list ();
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
#endif /* HAVE_CHARSET */
|
||||
/* *INDENT-ON* */
|
||||
#endif /* HAVE_CHARSET */
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
#undef ETALON_PATH_STR
|
||||
#define ETALON_PATH_STR "/test1://bla-bla/some/path/test2://user:passwd@some.host:1234/bla-bla/some/path/test3://111/22/33"
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_path_from_to_string_uri)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
vfs_path_t *vpath;
|
||||
size_t vpath_len;
|
||||
char *result;
|
||||
vpath = vfs_path_from_str (ETALON_PATH_STR);
|
||||
|
||||
vpath_len = vfs_path_elements_count(vpath);
|
||||
fail_unless(vpath_len == 4, "vpath length should be 4 (actial: %d)",vpath_len);
|
||||
vpath_len = vfs_path_elements_count (vpath);
|
||||
fail_unless (vpath_len == 4, "vpath length should be 4 (actial: %d)", vpath_len);
|
||||
|
||||
result = vfs_path_to_str(vpath);
|
||||
fail_unless(strcmp(ETALON_PATH_STR, result) == 0, "\nexpected(%s)\ndoesn't equal to actual(%s)", ETALON_PATH_STR, result);
|
||||
g_free(result);
|
||||
result = vfs_path_to_str (vpath);
|
||||
fail_unless (strcmp (ETALON_PATH_STR, result) == 0,
|
||||
"\nexpected(%s)\ndoesn't equal to actual(%s)", ETALON_PATH_STR, result);
|
||||
g_free (result);
|
||||
|
||||
vfs_path_free(vpath);
|
||||
vfs_path_free (vpath);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/vfs.c" /* for testing static methods */
|
||||
#include "lib/vfs/vfs.c" /* for testing static methods */
|
||||
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
@ -45,12 +45,9 @@ test_which (struct vfs_class *me, const char *path)
|
||||
{
|
||||
(void) me;
|
||||
|
||||
if (
|
||||
(strcmp(path, "test_1:") == 0) ||
|
||||
(strcmp(path, "test_2:") == 0) ||
|
||||
(strcmp(path, "test_3:") == 0) ||
|
||||
(strcmp(path, "test_4:") == 0)
|
||||
)
|
||||
if ((strcmp (path, "test_1:") == 0) ||
|
||||
(strcmp (path, "test_2:") == 0) ||
|
||||
(strcmp (path, "test_3:") == 0) || (strcmp (path, "test_4:") == 0))
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
@ -95,28 +92,45 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_prefix_to_class_valid)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
fail_unless(vfs_prefix_to_class((char *) "test_1:") == &vfs_test_ops1, "'test_1:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless(vfs_prefix_to_class((char *) "test_2:") == &vfs_test_ops1, "'test_2:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless(vfs_prefix_to_class((char *) "test_3:") == &vfs_test_ops1, "'test_3:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless(vfs_prefix_to_class((char *) "test_4:") == &vfs_test_ops1, "'test_4:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test_1:") == &vfs_test_ops1,
|
||||
"'test_1:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test_2:") == &vfs_test_ops1,
|
||||
"'test_2:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test_3:") == &vfs_test_ops1,
|
||||
"'test_3:' doesn't transform to vfs_test_ops1");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test_4:") == &vfs_test_ops1,
|
||||
"'test_4:' doesn't transform to vfs_test_ops1");
|
||||
|
||||
fail_unless(vfs_prefix_to_class((char *) "test2:") == &vfs_test_ops2, "'test2:' doesn't transform to vfs_test_ops2");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test2:") == &vfs_test_ops2,
|
||||
"'test2:' doesn't transform to vfs_test_ops2");
|
||||
|
||||
fail_unless(vfs_prefix_to_class((char *) "test3:") == &vfs_test_ops3, "'test3:' doesn't transform to vfs_test_ops3");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test3:") == &vfs_test_ops3,
|
||||
"'test3:' doesn't transform to vfs_test_ops3");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_prefix_to_class_invalid)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
fail_unless(vfs_prefix_to_class((char *) "test1:") == NULL, "'test1:' doesn't transform to NULL");
|
||||
fail_unless(vfs_prefix_to_class((char *) "test_5:") == NULL, "'test_5:' doesn't transform to NULL");
|
||||
fail_unless(vfs_prefix_to_class((char *) "test4:") == NULL, "'test4:' doesn't transform to NULL");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test1:") == NULL,
|
||||
"'test1:' doesn't transform to NULL");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test_5:") == NULL,
|
||||
"'test_5:' doesn't transform to NULL");
|
||||
fail_unless (vfs_prefix_to_class ((char *) "test4:") == NULL,
|
||||
"'test4:' doesn't transform to NULL");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/direntry.c" /* for testing static methods */
|
||||
#include "lib/vfs/direntry.c" /* for testing static methods */
|
||||
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
@ -44,25 +44,27 @@ struct vfs_s_subclass test_subclass1, test_subclass2, test_subclass3;
|
||||
struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
|
||||
|
||||
static int
|
||||
test1_mock_open_archive(struct vfs_s_super *super, const vfs_path_t *vpath, const vfs_path_element_t *vpath_element)
|
||||
test1_mock_open_archive (struct vfs_s_super *super, const vfs_path_t * vpath,
|
||||
const vfs_path_element_t * vpath_element)
|
||||
{
|
||||
struct vfs_s_inode *root;
|
||||
char *spath = vfs_path_to_str (vpath);
|
||||
|
||||
fail_unless(strcmp("/" ETALON_VFS_URL_NAME ARCH_NAME, spath) == 0,
|
||||
"etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_URL_NAME ARCH_NAME, spath);
|
||||
fail_unless (strcmp ("/" ETALON_VFS_URL_NAME ARCH_NAME, spath) == 0,
|
||||
"etalon(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_URL_NAME ARCH_NAME,
|
||||
spath);
|
||||
|
||||
super->name = g_strdup (spath);
|
||||
super->data = g_new (char *, 1);
|
||||
root = vfs_s_new_inode (vpath_element->class, super, NULL);
|
||||
super->root = root;
|
||||
g_free(spath);
|
||||
g_free (spath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
test1_mock_archive_same (const vfs_path_element_t *vpath_element, struct vfs_s_super *super,
|
||||
const vfs_path_t *vpath, void *cookie)
|
||||
test1_mock_archive_same (const vfs_path_element_t * vpath_element, struct vfs_s_super *super,
|
||||
const vfs_path_t * vpath, void *cookie)
|
||||
{
|
||||
const vfs_path_element_t *path_element;
|
||||
|
||||
@ -70,8 +72,8 @@ test1_mock_archive_same (const vfs_path_element_t *vpath_element, struct vfs_s_s
|
||||
(void) super;
|
||||
(void) cookie;
|
||||
|
||||
path_element = vfs_path_get_by_index(vpath, -1);
|
||||
if (strcmp(ARCH_NAME, path_element->path) != 0)
|
||||
path_element = vfs_path_get_by_index (vpath, -1);
|
||||
if (strcmp (ARCH_NAME, path_element->path) != 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@ -120,31 +122,37 @@ teardown (void)
|
||||
void
|
||||
vfs_die (const char *m)
|
||||
{
|
||||
printf("VFS_DIE: '%s'\n", m);
|
||||
printf ("VFS_DIE: '%s'\n", m);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_s_get_path)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
struct vfs_s_super *archive;
|
||||
|
||||
const char *result;
|
||||
vfs_path_t *vpath = vfs_path_from_str_flags ("/" ETALON_VFS_NAME ARCH_NAME "#test1:/" ETALON_PATH,
|
||||
VPF_USE_DEPRECATED_PARSER);
|
||||
vfs_path_t *vpath =
|
||||
vfs_path_from_str_flags ("/" ETALON_VFS_NAME ARCH_NAME "#test1:/" ETALON_PATH,
|
||||
VPF_USE_DEPRECATED_PARSER);
|
||||
|
||||
result = vfs_s_get_path (vpath, &archive, 0);
|
||||
|
||||
fail_unless(strcmp(ETALON_PATH, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH, result);
|
||||
fail_unless (strcmp (ETALON_PATH, result) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH, result);
|
||||
|
||||
fail_unless(strcmp("/" ETALON_VFS_URL_NAME ARCH_NAME,archive->name) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_URL_NAME ARCH_NAME, archive->name);
|
||||
fail_unless (strcmp ("/" ETALON_VFS_URL_NAME ARCH_NAME, archive->name) == 0,
|
||||
"expected(%s) doesn't equal to actual(%s)", "/" ETALON_VFS_URL_NAME ARCH_NAME,
|
||||
archive->name);
|
||||
|
||||
g_free(vpath);
|
||||
g_free (vpath);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib/vfs"
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include "lib/global.h"
|
||||
#include "lib/strutil.h"
|
||||
#include "lib/vfs/xdirentry.h"
|
||||
#include "lib/vfs/path.c" /* for testing static methods */
|
||||
#include "lib/vfs/path.c" /* for testing static methods */
|
||||
|
||||
#include "src/vfs/local/local.c"
|
||||
|
||||
@ -79,164 +79,236 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_split)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
const char *local, *op, *etalon_path, *etalon_local, *etalon_op;
|
||||
struct vfs_class *result;
|
||||
|
||||
path = g_strdup("#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/#test3:/qqq/www/eee.rr");
|
||||
path = g_strdup ("#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/#test3:/qqq/www/eee.rr");
|
||||
|
||||
etalon_path = "#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2/";
|
||||
etalon_local = "qqq/www/eee.rr";
|
||||
etalon_op = "test3:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops3, "Result(%p) doesn't match to vfs_test_ops3(%p)", result, &vfs_test_ops3);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops3, "Result(%p) doesn't match to vfs_test_ops3(%p)", result,
|
||||
&vfs_test_ops3);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
etalon_path = "#test1:/bla-bla/some/path/";
|
||||
etalon_local = "bla-bla/some/path2/";
|
||||
etalon_op = "test2:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
etalon_path = "";
|
||||
etalon_local = "bla-bla/some/path/";
|
||||
etalon_op = "test1:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops1, "Result(%p) doesn't match to vfs_test_ops1(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops1, "Result(%p) doesn't match to vfs_test_ops1(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == NULL, "Result(%p) doesn't match to vfs_test_ops1(NULL)", result);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == NULL, "Result(%p) doesn't match to vfs_test_ops1(NULL)", result);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
g_free(path);
|
||||
g_free (path);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_split_with_local)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
const char *local, *op, *etalon_path, *etalon_local, *etalon_op;
|
||||
struct vfs_class *result;
|
||||
|
||||
path = g_strdup("/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2#test3:/qqq/www/eee.rr");
|
||||
path =
|
||||
g_strdup
|
||||
("/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2#test3:/qqq/www/eee.rr");
|
||||
|
||||
etalon_path = "/local/path/#test1:/bla-bla/some/path/#test2:/bla-bla/some/path2";
|
||||
etalon_local = "qqq/www/eee.rr";
|
||||
etalon_op = "test3:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops3, "Result(%p) doesn't match to vfs_test_ops3(%p)", result, &vfs_test_ops3);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops3, "Result(%p) doesn't match to vfs_test_ops3(%p)", result,
|
||||
&vfs_test_ops3);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
etalon_path = "/local/path/#test1:/bla-bla/some/path/";
|
||||
etalon_local = "bla-bla/some/path2";
|
||||
etalon_op = "test2:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
etalon_path = "/local/path/";
|
||||
etalon_local = "bla-bla/some/path/";
|
||||
etalon_op = "test1:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops1, "Result(%p) doesn't match to vfs_test_ops1(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops1, "Result(%p) doesn't match to vfs_test_ops1(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'",
|
||||
local, etalon_local);
|
||||
fail_unless (strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == NULL, "Result(%p) doesn't match to vfs_test_ops1(NULL)", result);
|
||||
fail_unless (result == NULL, "Result(%p) doesn't match to vfs_test_ops1(NULL)", result);
|
||||
|
||||
g_free(path);
|
||||
g_free (path);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_split_url)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
const char *local, *op, *etalon_path, *etalon_local, *etalon_op;
|
||||
struct vfs_class *result;
|
||||
|
||||
path = g_strdup("#test2:username:passwd@somehost.net/bla-bla/some/path2");
|
||||
path = g_strdup ("#test2:username:passwd@somehost.net/bla-bla/some/path2");
|
||||
|
||||
etalon_path = "";
|
||||
etalon_local = "bla-bla/some/path2";
|
||||
etalon_op = "test2:username:passwd@somehost.net";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(path != NULL && strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(local != NULL && strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(op != NULL && strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (path != NULL
|
||||
&& strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (local != NULL
|
||||
&& strcmp (local, etalon_local) == 0,
|
||||
"parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless (op != NULL
|
||||
&& strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
g_free(path);
|
||||
g_free (path);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_split_url_with_semi)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
const char *local, *op, *etalon_path, *etalon_local, *etalon_op;
|
||||
struct vfs_class *result;
|
||||
|
||||
|
||||
path = g_strdup("/local/path/#test1:/bla-bla/some/path/#test2:username:p!a@s#s$w%d@somehost.net/bla-bla/some/path2");
|
||||
path =
|
||||
g_strdup
|
||||
("/local/path/#test1:/bla-bla/some/path/#test2:username:p!a@s#s$w%d@somehost.net/bla-bla/some/path2");
|
||||
|
||||
etalon_path = "/local/path/#test1:/bla-bla/some/path/";
|
||||
etalon_local = "bla-bla/some/path2";
|
||||
etalon_op = "test2:username:p!a@s#s$w%d@somehost.net";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(path != NULL && strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(local != NULL && strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(op != NULL && strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (path != NULL
|
||||
&& strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (local != NULL
|
||||
&& strcmp (local, etalon_local) == 0,
|
||||
"parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless (op != NULL
|
||||
&& strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
g_free(path);
|
||||
g_free (path);
|
||||
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_vfs_split_with_semi_in_path)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *path;
|
||||
const char *local, *op, *etalon_path, *etalon_local, *etalon_op;
|
||||
struct vfs_class *result;
|
||||
|
||||
path = g_strdup("#test2:/bl#a-bl#a/so#me/pa#th2");
|
||||
path = g_strdup ("#test2:/bl#a-bl#a/so#me/pa#th2");
|
||||
|
||||
etalon_path = "";
|
||||
etalon_local = "bl#a-bl#a/so#me/pa#th2";
|
||||
etalon_op = "test2:";
|
||||
result = _vfs_split_with_semi_skip_count (path, &local, &op, 0);
|
||||
fail_unless(result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result, &vfs_test_ops2);
|
||||
fail_unless(path != NULL && strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path, etalon_path);
|
||||
fail_unless(local != NULL && strcmp (local, etalon_local) == 0, "parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless(op != NULL && strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op, etalon_op);
|
||||
fail_unless (result == &vfs_test_ops2, "Result(%p) doesn't match to vfs_test_ops2(%p)", result,
|
||||
&vfs_test_ops2);
|
||||
fail_unless (path != NULL
|
||||
&& strcmp (path, etalon_path) == 0, "path('%s') doesn't match to '%s'", path,
|
||||
etalon_path);
|
||||
fail_unless (local != NULL
|
||||
&& strcmp (local, etalon_local) == 0,
|
||||
"parsed local path('%s') doesn't match to '%s'", local, etalon_local);
|
||||
fail_unless (op != NULL
|
||||
&& strcmp (op, etalon_op) == 0, "parsed VFS name ('%s') doesn't match to '%s'", op,
|
||||
etalon_op);
|
||||
|
||||
g_free(path);
|
||||
g_free (path);
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/lib"
|
||||
|
||||
@ -54,7 +54,9 @@ teardown (void)
|
||||
"\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result, etalon); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_x_basename)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
const char *result;
|
||||
check_x_basename ("/test/path/test2/path2", "path2");
|
||||
@ -72,7 +74,9 @@ START_TEST (test_x_basename)
|
||||
|
||||
check_x_basename ("/test/path/test2/path2/vfsprefix:///", "/");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/src/filemanager"
|
||||
|
||||
@ -129,7 +129,9 @@ teardown (void)
|
||||
g_free (result); \
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (test_examine_cd)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
char *result;
|
||||
|
||||
@ -156,7 +158,9 @@ START_TEST (test_examine_cd)
|
||||
check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
|
||||
check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
|
||||
}
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
*/
|
||||
|
||||
#define TEST_SUITE_NAME "/src/filemanager"
|
||||
|
||||
@ -52,8 +52,8 @@ setup (void)
|
||||
vfs_setup_work_dir ();
|
||||
|
||||
mc_global.mc_run_mode = MC_RUN_FULL;
|
||||
current_panel = g_new0(struct WPanel, 1);
|
||||
current_panel->cwd_vpath = vfs_path_from_str("/home");
|
||||
current_panel = g_new0 (struct WPanel, 1);
|
||||
current_panel->cwd_vpath = vfs_path_from_str ("/home");
|
||||
current_panel->dir.list = g_new0 (file_entry, MIN_FILES);
|
||||
current_panel->dir.size = MIN_FILES;
|
||||
}
|
||||
@ -67,23 +67,25 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
START_TEST (sanitize_variables)
|
||||
/* *INDENT-ON* */
|
||||
{
|
||||
/* given */
|
||||
vfs_path_t * filename_vpath;
|
||||
vfs_path_t *filename_vpath;
|
||||
char *actual_string;
|
||||
const char *expected_string;
|
||||
|
||||
current_panel->selected = 0;
|
||||
current_panel->dir.list[0].fname = (char*) "selected file.txt";
|
||||
current_panel->dir.list[1].fname = (char*) "tagged file1.txt";
|
||||
current_panel->dir.list[0].fname = (char *) "selected file.txt";
|
||||
current_panel->dir.list[1].fname = (char *) "tagged file1.txt";
|
||||
current_panel->dir.list[1].f.marked = TRUE;
|
||||
current_panel->dir.list[2].fname = (char*) "tagged file2.txt";
|
||||
current_panel->dir.list[2].fname = (char *) "tagged file2.txt";
|
||||
current_panel->dir.list[2].f.marked = TRUE;
|
||||
current_panel->count = 3;
|
||||
|
||||
/* when */
|
||||
filename_vpath = vfs_path_from_str("/tmp/blabla.txt");
|
||||
filename_vpath = vfs_path_from_str ("/tmp/blabla.txt");
|
||||
actual_string = exec_get_export_variables (filename_vpath);
|
||||
vfs_path_free (filename_vpath);
|
||||
|
||||
@ -104,8 +106,9 @@ export MC_EXT_ONLYTAGGED\n";
|
||||
|
||||
g_free (actual_string);
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
END_TEST
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user