2 lib/vfs - test vfs_get_encoding() functionality
4 Copyright (C) 2013-2024
5 Free Software Foundation, Inc.
8 Andrew Borodin <aborodin@vmail.ru>, 2013
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #define TEST_SUITE_NAME "/lib/vfs"
28 #include "tests/mctest.h"
30 #include "lib/vfs/path.h"
32 /* --------------------------------------------------------------------------------------------- */
40 /* --------------------------------------------------------------------------------------------- */
48 /* --------------------------------------------------------------------------------------------- */
50 /* @DataSource("test_vfs_get_encoding_ds") */
52 static const struct test_vfs_get_encoding_ds
55 const char *expected_encoding
;
56 } test_vfs_get_encoding_ds
[] =
87 "/aaaa/#enc:UTF-8/bbbb",
91 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R",
95 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R/cccc",
99 "/aaaa/#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
103 "/#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
107 "#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
111 "aaaa#enc:UTF-8/bbbb/cccc#enc:KOI8-R/dddd",
115 "/aaaa/#enc:UTF-8/bbbb/#enc:KOI8-R#enc:CP866/cccc",
121 /* @Test(dataSource = "test_vfs_get_encoding_ds") */
123 START_PARAMETRIZED_TEST (test_vfs_get_encoding
, test_vfs_get_encoding_ds
)
127 char *actual_encoding
;
130 actual_encoding
= vfs_get_encoding (data
->path
, -1);
133 mctest_assert_str_eq (actual_encoding
, data
->expected_encoding
);
135 g_free (actual_encoding
);
138 END_PARAMETRIZED_TEST
141 /* --------------------------------------------------------------------------------------------- */
148 tc_core
= tcase_create ("Core");
150 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
152 /* Add new tests here: *************** */
153 mctest_add_parameterized_test (tc_core
, test_vfs_get_encoding
, test_vfs_get_encoding_ds
);
154 /* *********************************** */
156 return mctest_run_all (tc_core
);
159 /* --------------------------------------------------------------------------------------------- */