Code refactoring in tests.

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2013-02-14 14:44:35 +03:00 committed by Andrew Borodin
parent b3bc856974
commit 79ee80c201
12 changed files with 179 additions and 179 deletions

View File

@ -116,7 +116,7 @@ static const struct test_create_ini_file_ds
"param-not_exists",
NULL,
NULL,
"" /* it's a bug: should be NULL. Will be fixed in another branch */
NULL
},
{ /* 1. */
"test-group1",

View File

@ -1,11 +1,12 @@
/*
libmc - checks for processing esc sequences in replace string
Copyright (C) 2011
Copyright (C) 2011, 2013
The Free Software Foundation, Inc.
Written by:
Andrew Borodin <aborodin@vmail.ru>, 2011
Slava Zanko <slavazanko@gmail.com>, 2013
This file is part of the Midnight Commander.
@ -21,38 +22,60 @@
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/glob"
#include <config.h>
#include "tests/mctest.h"
#include <check.h>
#include "glob.c" /* for testing static functions */
#include "glob.c" /* for testing static functions */
/* --------------------------------------------------------------------------------------------- */
static void
test_helper_valid_data (const char *from, const char *etalon)
/* @DataSource("test_translate_replace_glob_to_regex_ds") */
/* *INDENT-OFF* */
static const struct test_translate_replace_glob_to_regex_ds
{
const char *input_value;
const char *expected_result;
} test_translate_replace_glob_to_regex_ds[] =
{
{
"a&a?a",
"a\\&a\\1a"
},
{
"a\\&a?a",
"a\\&a\\1a"
},
{
"a&a\\?a",
"a\\&a\\?a"
},
{
"a\\&a\\?a",
"a\\&a\\?a"
},
};
/* *INDENT-ON* */
/* @Test(dataSource = "test_translate_replace_glob_to_regex_ds") */
/* *INDENT-OFF* */
START_PARAMETRIZED_TEST (test_translate_replace_glob_to_regex, test_translate_replace_glob_to_regex_ds)
/* *INDENT-ON* */
{
/* given */
GString *dest_str;
dest_str = mc_search__translate_replace_glob_to_regex (from);
fail_if (strcmp (dest_str->str, etalon), "dest_str(%s) != %s", dest_str->str, etalon);
g_string_free (dest_str, TRUE);
}
/* when */
dest_str = mc_search__translate_replace_glob_to_regex (data->input_value);
/* --------------------------------------------------------------------------------------------- */
START_TEST (test_translate_replace_glob_to_regex)
{
test_helper_valid_data ("a&a?a", "a\\&a\\1a");
test_helper_valid_data ("a\\&a?a", "a\\&a\\1a");
test_helper_valid_data ("a&a\\?a", "a\\&a\\?a");
test_helper_valid_data ("a\\&a\\?a", "a\\&a\\?a");
/* then */
mctest_assert_str_eq (dest_str->str, data->expected_result) g_string_free (dest_str, TRUE);
}
END_TEST
/* *INDENT-OFF* */
END_PARAMETRIZED_TEST
/* *INDENT-ON* */
/* --------------------------------------------------------------------------------------------- */
@ -66,7 +89,8 @@ main (void)
SRunner *sr;
/* Add new tests here: *************** */
tcase_add_test (tc_core, test_translate_replace_glob_to_regex);
mctest_add_parameterized_test (tc_core, test_translate_replace_glob_to_regex,
test_translate_replace_glob_to_regex_ds);
/* *********************************** */
suite_add_tcase (s, tc_core);

View File

@ -25,10 +25,8 @@
#define TEST_SUITE_NAME "/lib/strutil"
#include <config.h>
#include <check.h>
#include "tests/mctest.h"
#include "lib/global.h"
#include "lib/strutil.h"
/* --------------------------------------------------------------------------------------------- */
@ -62,84 +60,84 @@ static const struct str_replace_all_test_ds
} str_replace_all_test_ds[] =
{
{
/*needle not found*/
/* 0. needle not found*/
"needle not found",
"blablablabla",
"1234567890",
"needle not found",
},
{
/* replacement is less rather that needle */
/* 1. replacement is less rather that needle */
"some string blablablabla string",
"blablablabla",
"1234",
"some string 1234 string",
},
{
/* replacement is great rather that needle */
/* 2. replacement is great rather that needle */
"some string bla string",
"bla",
"1234567890",
"some string 1234567890 string",
},
{
/* replace few substrings in a start of string */
/* 3. replace few substrings in a start of string */
"blabla blabla string",
"blabla",
"111111111",
"111111111 111111111 string",
},
{
/* replace few substrings in a middle of string */
/* 4. replace few substrings in a middle of string */
"some string blabla str blabla string",
"blabla",
"111111111",
"some string 111111111 str 111111111 string",
},
{
/* replace few substrings in an end of string */
/* 5. replace few substrings in an end of string */
"some string blabla str blabla",
"blabla",
"111111111",
"some string 111111111 str 111111111",
},
{
/* escaped substring */
/* 6. escaped substring */
"\\blabla blabla",
"blabla",
"111111111",
"blabla 111111111",
},
{
/* escaped substring */
/* 7. escaped substring */
"str \\blabla blabla",
"blabla",
"111111111",
"str blabla 111111111",
},
{
/* escaped substring */
/* 8. escaped substring */
"str \\\\\\blabla blabla",
"blabla",
"111111111",
"str \\\\blabla 111111111",
},
{
/* double-escaped substring (actually non-escaped) */
/* 9. double-escaped substring (actually non-escaped) */
"\\\\blabla blabla",
"blabla",
"111111111",
"\\\\111111111 111111111",
},
{
/* partial substring */
/* 10. partial substring */
"blablabla",
"blabla",
"111111111",
"111111111bla",
},
{
/* special symbols */
/* 11. special symbols */
"bla bla",
"bla",
"111\t1 1\n1111",
@ -150,12 +148,11 @@ static const struct str_replace_all_test_ds
/* @Test(dataSource = "str_replace_all_test_ds") */
/* *INDENT-OFF* */
START_TEST (str_replace_all_test)
START_PARAMETRIZED_TEST (str_replace_all_test, str_replace_all_test_ds)
/* *INDENT-ON* */
{
/* given */
char *actual_result;
const struct str_replace_all_test_ds *data = &str_replace_all_test_ds[_i];
/* when */
actual_result = str_replace_all (data->haystack, data->needle, data->replacement);
@ -163,10 +160,9 @@ START_TEST (str_replace_all_test)
/* then */
g_assert_cmpstr (actual_result, ==, data->expected_result);
g_free (actual_result);
}
/* *INDENT-OFF* */
END_TEST
END_PARAMETRIZED_TEST
/* *INDENT-ON* */
/* --------------------------------------------------------------------------------------------- */
@ -183,14 +179,13 @@ main (void)
tcase_add_checked_fixture (tc_core, setup, teardown);
/* Add new tests here: *************** */
tcase_add_loop_test (tc_core, str_replace_all_test, 0,
sizeof (str_replace_all_test_ds) / sizeof (str_replace_all_test_ds[0]));
mctest_add_parameterized_test (tc_core, str_replace_all_test, str_replace_all_test_ds);
/* *********************************** */
suite_add_tcase (s, tc_core);
sr = srunner_create (s);
srunner_set_log (sr, "replace__str_replace_all.log");
srunner_run_all (sr, CK_NOFORK);
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
return (number_failed == 0) ? 0 : 1;

View File

@ -26,8 +26,7 @@
#include <signal.h>
#include <unistd.h>
#include "lib/global.h"
#include "lib/vfs/vfs.h"
/* --------------------------------------------------------------------------------------------- */
@ -228,8 +227,8 @@ execvp__deinit (void)
#define VERIFY_SIGACTION__ACT_IGNORED(_pntr) { \
struct sigaction *_act = (struct sigaction *) _pntr; \
fail_unless (_act->sa_handler == SIG_IGN, " sa_handler should be equals to SIG_IGN"); \
ck_assert_int_eq (_act->sa_flags, 0); \
mctest_assert_ptr_eq (_act->sa_handler, SIG_IGN); \
mctest_assert_int_eq (_act->sa_flags, 0); \
}
#define VERIFY_SIGACTION__IS_RESTORED(oldact_idx, act_idx) { \
@ -241,14 +240,14 @@ execvp__deinit (void)
/* @Verify */
#define VERIFY_SIGACTION_CALLS() { \
ck_assert_int_eq (sigaction_signum__captured->len, 6); \
mctest_assert_int_eq (sigaction_signum__captured->len, 6); \
\
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 0)), SIGINT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 1)), SIGQUIT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 2)), SIGTSTP); \
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 3)), SIGINT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 4)), SIGQUIT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 5)), SIGTSTP); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 0)), SIGINT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 1)), SIGQUIT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 2)), SIGTSTP); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 3)), SIGINT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 4)), SIGQUIT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(sigaction_signum__captured, 5)), SIGTSTP); \
\
VERIFY_SIGACTION__ACT_IGNORED(g_ptr_array_index(sigaction_act__captured, 0)); \
VERIFY_SIGACTION__ACT_IGNORED(g_ptr_array_index(sigaction_act__captured, 1)); \
@ -274,17 +273,16 @@ execvp__deinit (void)
#define VERIFY_SIGNAL_HANDLER_IS_SIG_DFL(_idx) { \
sighandler_t *tmp_handler = (sighandler_t *) g_ptr_array_index(signal_handler__captured, _idx);\
fail_unless (tmp_handler == (sighandler_t *) SIG_DFL, \
"signal handler should be SIG_DFL"); \
mctest_assert_ptr_eq (tmp_handler, (sighandler_t *) SIG_DFL); \
}
/* @Verify */
#define VERIFY_SIGNAL_CALLS() { \
ck_assert_int_eq (signal_signum__captured->len, 4); \
ck_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 0)), SIGINT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 1)), SIGQUIT); \
ck_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 2)), SIGTSTP); \
ck_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 3)), SIGCHLD); \
mctest_assert_int_eq (signal_signum__captured->len, 4); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 0)), SIGINT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 1)), SIGQUIT); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 2)), SIGTSTP); \
mctest_assert_int_eq (*((int *) g_ptr_array_index(signal_signum__captured, 3)), SIGCHLD); \
\
VERIFY_SIGNAL_HANDLER_IS_SIG_DFL (0); \
VERIFY_SIGNAL_HANDLER_IS_SIG_DFL (1); \

View File

@ -25,10 +25,7 @@
#define TEST_SUITE_NAME "/lib/utilunix"
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "tests/mctest.h"
#include "lib/util.h"
#include "lib/utilunix.h"
@ -49,19 +46,19 @@ START_TEST (fork_child)
actual_value = my_system (0, "/bin/some-command", "some parameter");
/* then */
ck_assert_int_eq (actual_value, 0);
mctest_assert_int_eq (actual_value, 0);
VERIFY_SIGACTION_CALLS ();
VERIFY_SIGNAL_CALLS ();
g_assert_cmpstr (execvp__file__captured, ==, "/bin/some-command");
ck_assert_int_eq (execvp__args__captured->len, 2);
mctest_assert_str_eq (execvp__file__captured, "/bin/some-command");
mctest_assert_int_eq (execvp__args__captured->len, 2);
g_assert_cmpstr (g_ptr_array_index (execvp__args__captured, 0), ==, "/bin/some-command");
g_assert_cmpstr (g_ptr_array_index (execvp__args__captured, 1), ==, "some parameter");
mctest_assert_str_eq (g_ptr_array_index (execvp__args__captured, 0), "/bin/some-command");
mctest_assert_str_eq (g_ptr_array_index (execvp__args__captured, 1), "some parameter");
/* All exec* calls is mocked, so call to _exit() function with 127 status code it's a normal situation */
ck_assert_int_eq (my_exit__status__captured, 127);
mctest_assert_int_eq (my_exit__status__captured, 127);
}
/* *INDENT-OFF* */
END_TEST

View File

@ -25,10 +25,7 @@
#define TEST_SUITE_NAME "/lib/utilunix"
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "tests/mctest.h"
#include "lib/util.h"
#include "lib/utilunix.h"
@ -49,20 +46,20 @@ START_TEST (fork_child_as_shell)
actual_value = my_system (EXECUTE_AS_SHELL, "/bin/shell", "some command");
/* then */
ck_assert_int_eq (actual_value, 0);
mctest_assert_int_eq (actual_value, 0);
VERIFY_SIGACTION_CALLS ();
VERIFY_SIGNAL_CALLS ();
g_assert_cmpstr (execvp__file__captured, ==, "/bin/shell");
ck_assert_int_eq (execvp__args__captured->len, 3);
mctest_assert_str_eq (execvp__file__captured, "/bin/shell");
mctest_assert_int_eq (execvp__args__captured->len, 3);
g_assert_cmpstr (g_ptr_array_index (execvp__args__captured, 0), ==, "/bin/shell");
g_assert_cmpstr (g_ptr_array_index (execvp__args__captured, 1), ==, "-c");
g_assert_cmpstr (g_ptr_array_index (execvp__args__captured, 2), ==, "some command");
mctest_assert_str_eq (g_ptr_array_index (execvp__args__captured, 0), "/bin/shell");
mctest_assert_str_eq (g_ptr_array_index (execvp__args__captured, 1), "-c");
mctest_assert_str_eq (g_ptr_array_index (execvp__args__captured, 2), "some command");
/* All exec* calls is mocked, so call to _exit() function with 127 status code it's a normal situation */
ck_assert_int_eq (my_exit__status__captured, 127);
mctest_assert_int_eq (my_exit__status__captured, 127);
}
/* *INDENT-OFF* */
END_TEST

View File

@ -25,12 +25,10 @@
#define TEST_SUITE_NAME "/lib/utilunix"
#include <config.h>
#include "tests/mctest.h"
#include <signal.h>
#include <unistd.h>
#include <check.h>
#include "lib/global.h"
#include "lib/util.h"
#include "lib/utilunix.h"
@ -52,11 +50,11 @@ START_TEST (fork_fail)
actual_value = my_system (0, NULL, NULL);
/* then */
ck_assert_int_eq (actual_value, -1);
mctest_assert_int_eq (actual_value, -1);
VERIFY_SIGACTION_CALLS ();
ck_assert_int_eq (signal_signum__captured->len, 0);
mctest_assert_int_eq (signal_signum__captured->len, 0);
}
/* *INDENT-OFF* */
END_TEST

View File

@ -316,7 +316,7 @@ static const struct test_vfs_path_append_vpath_ds
{
const char *input_path1;
const char *input_path2;
const size_t expected_element_count;
const int expected_element_count;
const char *expected_path;
} test_vfs_path_append_vpath_ds[] =
{

View File

@ -26,7 +26,7 @@
#include "lib/widget.h"
#include "lib/strutil.h"
#include "lib/vfs/path.h"
#include "lib/vfs/vfs.h"
#include "src/vfs/local/local.c"
#include "src/execute.h"

View File

@ -25,11 +25,7 @@
#define TEST_SUITE_NAME "/src"
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "tests/mctest.h"
#include "execute__common.c"
@ -158,23 +154,25 @@ START_TEST (do_open_external_editor_or_viewer)
/* then */
/* check call to execute_get_external_cmd_opts_from_config() */
g_assert_cmpstr (execute_external_cmd_opts__command__captured, ==, "editor_or_viewer");
ck_assert_int_eq (vfs_path_cmp
(execute_external_cmd_opts__filename_vpath__captured, filename_vpath), 0);
ck_assert_int_eq (execute_external_cmd_opts__start_line__captured, 123);
mctest_assert_str_eq (execute_external_cmd_opts__command__captured, "editor_or_viewer");
mctest_assert_int_eq (vfs_path_equal
(execute_external_cmd_opts__filename_vpath__captured, filename_vpath),
TRUE);
mctest_assert_int_eq (execute_external_cmd_opts__start_line__captured, 123);
/* check call to do_executev() */
g_assert_cmpstr (do_executev__lc_shell__captured, ==, "editor_or_viewer");
ck_assert_int_eq (do_executev__flags__captured, EXECUTE_INTERNAL);
ck_assert_int_eq (do_executev__argv__captured->len, 7);
mctest_assert_str_eq (do_executev__lc_shell__captured, "editor_or_viewer");
mctest_assert_int_eq (do_executev__flags__captured, EXECUTE_INTERNAL);
mctest_assert_int_eq (do_executev__argv__captured->len, 7);
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 0), ==, "param 1 with spaces");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 1), ==, "param 2");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 2), ==, "-a");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 3), ==, "-b");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 4), ==, "-cdef");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 5), ==, "/path/to/file.txt");
g_assert_cmpstr (g_ptr_array_index (do_executev__argv__captured, 6), ==, "+123");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 0),
"param 1 with spaces");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 1), "param 2");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 2), "-a");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 3), "-b");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 4), "-cdef");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 5), "/path/to/file.txt");
mctest_assert_str_eq (g_ptr_array_index (do_executev__argv__captured, 6), "+123");
vfs_path_free (filename_vpath);
}

View File

@ -25,14 +25,11 @@
#define TEST_SUITE_NAME "/src"
#include <config.h>
#include "tests/mctest.h"
#include <check.h>
#include "lib/global.h"
#include "lib/mcconfig.h"
#include "lib/strutil.h"
#include "lib/vfs/path.h"
#include "lib/vfs/vfs.h"
#include "src/vfs/local/local.c"
char *execute_get_external_cmd_opts_from_config (const char *command,
@ -150,11 +147,10 @@ static const struct check_subtitute_ds
/* @Test(dataSource = "check_subtitute_ds") */
/* *INDENT-OFF* */
START_TEST (check_if_filename_and_lineno_will_be_subtituted)
START_PARAMETRIZED_TEST (check_if_filename_and_lineno_will_be_subtituted, check_subtitute_ds)
/* *INDENT-ON* */
{
/* given */
const struct check_subtitute_ds *data = &check_subtitute_ds[_i];
char *actual_result;
vfs_path_t *filename_vpath;
@ -169,21 +165,21 @@ START_TEST (check_if_filename_and_lineno_will_be_subtituted)
/* then */
/* check returned value */
g_assert_cmpstr (actual_result, ==, data->expected_result);
mctest_assert_str_eq (actual_result, data->expected_result);
/* check calls to mc_config_get_string() function */
g_assert_cmpstr (g_ptr_array_index (mc_config_get_string__group__captured, 0), ==,
CONFIG_EXT_EDITOR_VIEWER_SECTION);
g_assert_cmpstr (g_ptr_array_index (mc_config_get_string__param__captured, 0), ==,
data->app_name);
g_assert_cmpstr (g_ptr_array_index (mc_config_get_string__default_value__captured, 0), ==,
NULL);
mctest_assert_str_eq (g_ptr_array_index (mc_config_get_string__group__captured, 0),
CONFIG_EXT_EDITOR_VIEWER_SECTION);
mctest_assert_str_eq (g_ptr_array_index (mc_config_get_string__param__captured, 0),
data->app_name);
mctest_assert_str_eq (g_ptr_array_index (mc_config_get_string__default_value__captured, 0),
NULL);
vfs_path_free (filename_vpath);
}
/* *INDENT-OFF* */
END_TEST
END_PARAMETRIZED_TEST
/* *INDENT-ON* */
/* --------------------------------------------------------------------------------------------- */
@ -200,8 +196,8 @@ main (void)
tcase_add_checked_fixture (tc_core, setup, teardown);
/* Add new tests here: *************** */
tcase_add_loop_test (tc_core, check_if_filename_and_lineno_will_be_subtituted, 0,
sizeof (check_subtitute_ds) / sizeof (check_subtitute_ds[0]));
mctest_add_parameterized_test (tc_core, check_if_filename_and_lineno_will_be_subtituted,
check_subtitute_ds);
/* *********************************** */
suite_add_tcase (s, tc_core);

View File

@ -25,11 +25,7 @@
#define TEST_SUITE_NAME "/src"
#include <config.h>
#include <check.h>
#include "lib/global.h"
#include "tests/mctest.h"
#include "execute__common.c"
@ -53,13 +49,12 @@ static const struct the_file_is_local_ds
/* @Test(dataSource = "the_file_is_local_ds") */
/* *INDENT-OFF* */
START_TEST (the_file_is_local)
START_PARAMETRIZED_TEST (the_file_is_local, the_file_is_local_ds)
/* *INDENT-ON* */
{
/* given */
vfs_path_t *filename_vpath;
const char *input_path = the_file_is_local_ds[_i].input_path;
filename_vpath = vfs_path_from_str (input_path);
filename_vpath = vfs_path_from_str (data->input_path);
vfs_file_is_local__return_value = TRUE;
@ -67,26 +62,26 @@ START_TEST (the_file_is_local)
execute_with_vfs_arg ("cmd_for_local_file", filename_vpath);
/* then */
g_assert_cmpstr (do_execute__lc_shell__captured, ==, "cmd_for_local_file");
g_assert_cmpstr (do_execute__command__captured, ==, input_path);
mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_local_file");
mctest_assert_str_eq (do_execute__command__captured, data->input_path);
ck_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
{
const vfs_path_t *tmp_vpath;
tmp_vpath = (input_path == NULL) ? vfs_get_raw_current_dir () : filename_vpath;
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), tmp_vpath),
0);
tmp_vpath = (data->input_path == NULL) ? vfs_get_raw_current_dir () : filename_vpath;
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0),
tmp_vpath), TRUE);
}
ck_assert_int_eq (do_execute__flags__captured, EXECUTE_INTERNAL);
mctest_assert_int_eq (do_execute__flags__captured, EXECUTE_INTERNAL);
fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL,
"\nFunction mc_getlocalcopy() shouldn't be called!");
vfs_path_free (filename_vpath);
}
/* *INDENT-OFF* */
END_TEST
END_PARAMETRIZED_TEST
/* *INDENT-ON* */
/* --------------------------------------------------------------------------------------------- */
@ -106,14 +101,14 @@ START_TEST (the_file_is_remote_but_empty)
execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath);
/* then */
g_assert_cmpstr (do_execute__lc_shell__captured, ==, NULL);
g_assert_cmpstr (do_execute__command__captured, ==, NULL);
mctest_assert_str_eq (do_execute__lc_shell__captured, NULL);
mctest_assert_str_eq (do_execute__command__captured, NULL);
ck_assert_int_eq (vfs_file_is_local__vpath__captured->len, 2);
mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 2);
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0),
vfs_get_raw_current_dir ()), 0);
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0),
vfs_get_raw_current_dir ()), TRUE);
fail_unless (g_ptr_array_index (vfs_file_is_local__vpath__captured, 1) == NULL,
"\nParameter for second call to vfs_file_is_local() should be NULL!");
fail_unless (mc_getlocalcopy__pathname_vpath__captured == NULL,
@ -144,20 +139,21 @@ START_TEST (the_file_is_remote_fail_to_create_local_copy)
execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath);
/* then */
g_assert_cmpstr (do_execute__lc_shell__captured, ==, NULL);
g_assert_cmpstr (do_execute__command__captured, ==, NULL);
mctest_assert_str_eq (do_execute__lc_shell__captured, NULL);
mctest_assert_str_eq (do_execute__command__captured, NULL);
ck_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), filename_vpath),
0);
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0),
filename_vpath), TRUE);
ck_assert_int_eq (vfs_path_cmp (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), 0);
mctest_assert_int_eq (vfs_path_equal
(mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE);
g_assert_cmpstr (message_title__captured, ==, _("Error"));
g_assert_cmpstr (message_text__captured, ==,
_("Cannot fetch a local copy of /ftp://some.host/editme.txt"));
mctest_assert_str_eq (message_title__captured, _("Error"));
mctest_assert_str_eq (message_text__captured,
_("Cannot fetch a local copy of /ftp://some.host/editme.txt"));
vfs_path_free (filename_vpath);
@ -187,29 +183,31 @@ START_TEST (the_file_is_remote)
execute_with_vfs_arg ("cmd_for_remote_file", filename_vpath);
/* then */
g_assert_cmpstr (do_execute__lc_shell__captured, ==, "cmd_for_remote_file");
g_assert_cmpstr (do_execute__command__captured, ==, "/tmp/blabla-editme.txt");
mctest_assert_str_eq (do_execute__lc_shell__captured, "cmd_for_remote_file");
mctest_assert_str_eq (do_execute__command__captured, "/tmp/blabla-editme.txt");
ck_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
mctest_assert_int_eq (vfs_file_is_local__vpath__captured->len, 1);
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0), filename_vpath),
0);
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (vfs_file_is_local__vpath__captured, 0),
filename_vpath), TRUE);
ck_assert_int_eq (vfs_path_cmp (mc_getlocalcopy__pathname_vpath__captured, filename_vpath), 0);
mctest_assert_int_eq (vfs_path_equal
(mc_getlocalcopy__pathname_vpath__captured, filename_vpath), TRUE);
ck_assert_int_eq (mc_stat__vpath__captured->len, 2);
mctest_assert_int_eq (mc_stat__vpath__captured->len, 2);
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (mc_stat__vpath__captured, 0), local_vpath), 0);
ck_assert_int_eq (vfs_path_cmp
(g_ptr_array_index (mc_stat__vpath__captured, 0),
g_ptr_array_index (mc_stat__vpath__captured, 1)), 0);
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (mc_stat__vpath__captured, 0), local_vpath), TRUE);
mctest_assert_int_eq (vfs_path_equal
(g_ptr_array_index (mc_stat__vpath__captured, 0),
g_ptr_array_index (mc_stat__vpath__captured, 1)), TRUE);
ck_assert_int_eq (vfs_path_cmp (mc_ungetlocalcopy__pathname_vpath__captured, filename_vpath),
0);
mctest_assert_int_eq (vfs_path_equal
(mc_ungetlocalcopy__pathname_vpath__captured, filename_vpath), TRUE);
ck_assert_int_eq (vfs_path_cmp (mc_ungetlocalcopy__local_vpath__captured, local_vpath), 0);
mctest_assert_int_eq (vfs_path_equal (mc_ungetlocalcopy__local_vpath__captured, local_vpath),
TRUE);
vfs_path_free (filename_vpath);
vfs_path_free (local_vpath);
@ -232,8 +230,7 @@ main (void)
tcase_add_checked_fixture (tc_core, setup, teardown);
/* Add new tests here: *************** */
tcase_add_loop_test (tc_core, the_file_is_local, 0,
sizeof (the_file_is_local_ds) / sizeof (the_file_is_local_ds[0]));
mctest_add_parameterized_test (tc_core, the_file_is_local, the_file_is_local_ds);
tcase_add_test (tc_core, the_file_is_remote_but_empty);
tcase_add_test (tc_core, the_file_is_remote_fail_to_create_local_copy);
tcase_add_test (tc_core, the_file_is_remote);