Merge branch '4549_subshell_execl_argv0'
[midnight-commander.git] / tests / lib / search / translate_replace_glob_to_regex.c
blob535bcb2a4974648cd40e667626ef3b59b963ce8d
1 /*
2 libmc - checks for processing esc sequences in replace string
4 Copyright (C) 2011-2024
5 Free Software Foundation, Inc.
7 Written by:
8 Andrew Borodin <aborodin@vmail.ru>, 2011
9 Slava Zanko <slavazanko@gmail.com>, 2013
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #define TEST_SUITE_NAME "lib/search/glob"
29 #include "tests/mctest.h"
31 #include "glob.c" /* for testing static functions */
33 /* --------------------------------------------------------------------------------------------- */
35 /* @DataSource("test_translate_replace_glob_to_regex_ds") */
36 /* *INDENT-OFF* */
37 static const struct test_translate_replace_glob_to_regex_ds
39 const char *input_value;
40 const char *expected_result;
41 } test_translate_replace_glob_to_regex_ds[] =
44 "a&a?a",
45 "a\\&a\\1a"
48 "a\\&a?a",
49 "a\\&a\\1a"
52 "a&a\\?a",
53 "a\\&a\\?a"
56 "a\\&a\\?a",
57 "a\\&a\\?a"
60 /* *INDENT-ON* */
62 /* @Test(dataSource = "test_translate_replace_glob_to_regex_ds") */
63 /* *INDENT-OFF* */
64 START_PARAMETRIZED_TEST (test_translate_replace_glob_to_regex, test_translate_replace_glob_to_regex_ds)
65 /* *INDENT-ON* */
67 /* given */
68 GString *dest_str;
70 /* when */
71 dest_str = mc_search__translate_replace_glob_to_regex (data->input_value);
73 /* then */
74 mctest_assert_str_eq (dest_str->str, data->expected_result);
75 g_string_free (dest_str, TRUE);
77 /* *INDENT-OFF* */
78 END_PARAMETRIZED_TEST
79 /* *INDENT-ON* */
81 /* --------------------------------------------------------------------------------------------- */
83 int
84 main (void)
86 TCase *tc_core;
88 tc_core = tcase_create ("Core");
90 /* Add new tests here: *************** */
91 mctest_add_parameterized_test (tc_core, test_translate_replace_glob_to_regex,
92 test_translate_replace_glob_to_regex_ds);
93 /* *********************************** */
95 return mctest_run_all (tc_core);
98 /* --------------------------------------------------------------------------------------------- */