1 /* lib/vfs - test vfs_path_from_str_flags() function
3 Copyright (C) 2013-2017
4 Free Software Foundation, Inc.
7 Slava Zanko <slavazanko@gmail.com>, 2013
9 This file is part of the Midnight Commander.
11 The Midnight Commander is free software: you can redistribute it
12 and/or modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation, either version 3 of the License,
14 or (at your option) any later version.
16 The Midnight Commander is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #define TEST_SUITE_NAME "/lib/vfs"
27 #include "tests/mctest.h"
29 #include "lib/strutil.h"
30 #include "lib/vfs/xdirentry.h"
31 #include "lib/vfs/path.h"
33 #include "src/vfs/local/local.c"
35 /* --------------------------------------------------------------------------------------------- */
39 mc_config_get_home_dir (void)
44 /* --------------------------------------------------------------------------------------------- */
49 str_init_strings (NULL
);
53 vfs_setup_work_dir ();
56 /* --------------------------------------------------------------------------------------------- */
63 str_uninit_strings ();
66 /* --------------------------------------------------------------------------------------------- */
68 /* @DataSource("test_from_to_string_ds") */
70 static const struct test_strip_home_ds
72 const char *input_string
;
73 const char *expected_result
;
74 } test_strip_home_ds
[] =
77 "/mock/test/some/path",
81 "/mock/testttt/some/path",
82 "/mock/testttt/some/path"
89 START_PARAMETRIZED_TEST (test_strip_home
, test_strip_home_ds
)
93 vfs_path_t
*actual_result
;
96 actual_result
= vfs_path_from_str_flags (data
->input_string
, VPF_STRIP_HOME
);
99 mctest_assert_str_eq (actual_result
->str
, data
->expected_result
);
101 vfs_path_free (actual_result
);
104 END_PARAMETRIZED_TEST
107 /* --------------------------------------------------------------------------------------------- */
114 Suite
*s
= suite_create (TEST_SUITE_NAME
);
115 TCase
*tc_core
= tcase_create ("Core");
118 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
120 /* Add new tests here: *************** */
121 mctest_add_parameterized_test (tc_core
, test_strip_home
, test_strip_home_ds
);
122 /* *********************************** */
124 suite_add_tcase (s
, tc_core
);
125 sr
= srunner_create (s
);
126 srunner_set_log (sr
, "vfs_path_from_str_flags.log");
127 srunner_run_all (sr
, CK_ENV
);
128 number_failed
= srunner_ntests_failed (sr
);
130 return (number_failed
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;
133 /* --------------------------------------------------------------------------------------------- */