2 libmc - checks for processing esc sequences in replace string
4 Copyright (C) 2011-2024
5 Free Software Foundation, Inc.
8 Slava Zanko <slavazanko@gmail.com>, 2011, 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/search/regex"
28 #include "tests/mctest.h"
30 #include "regex.c" /* for testing static functions */
32 /* --------------------------------------------------------------------------------------------- */
34 /* @DataSource("test_regex_process_escape_sequence_ds") */
36 static const struct test_regex_process_escape_sequence_ds
38 const char *input_from
;
39 const replace_transform_type_t input_initial_flags
;
40 const gboolean input_use_utf
;
41 const char *expected_string
;
42 } test_regex_process_escape_sequence_ds
[] =
46 REPLACE_T_NO_TRANSFORM
,
52 REPLACE_T_NO_TRANSFORM
,
58 REPLACE_T_NO_TRANSFORM
,
64 REPLACE_T_NO_TRANSFORM
,
70 REPLACE_T_NO_TRANSFORM
,
76 REPLACE_T_NO_TRANSFORM
,
82 REPLACE_T_NO_TRANSFORM
,
88 REPLACE_T_NO_TRANSFORM
,
94 REPLACE_T_NO_TRANSFORM
,
100 REPLACE_T_NO_TRANSFORM
,
106 REPLACE_T_NO_TRANSFORM
,
113 /* @Test(dataSource = "test_regex_process_escape_sequence_ds") */
115 START_PARAMETRIZED_TEST (test_regex_process_escape_sequence
, test_regex_process_escape_sequence_ds
)
119 GString
*actual_string
;
120 replace_transform_type_t replace_flags
= REPLACE_T_NO_TRANSFORM
;
122 replace_flags
= data
->input_initial_flags
;
123 actual_string
= g_string_new ("");
126 mc_search_regex__process_escape_sequence (actual_string
, data
->input_from
, -1, &replace_flags
,
127 data
->input_use_utf
);
130 mctest_assert_str_eq (actual_string
->str
, data
->expected_string
);
132 g_string_free (actual_string
, TRUE
);
135 END_PARAMETRIZED_TEST
138 /* --------------------------------------------------------------------------------------------- */
145 tc_core
= tcase_create ("Core");
147 /* Add new tests here: *************** */
148 mctest_add_parameterized_test (tc_core
, test_regex_process_escape_sequence
,
149 test_regex_process_escape_sequence_ds
);
150 /* *********************************** */
152 return mctest_run_all (tc_core
);
155 /* --------------------------------------------------------------------------------------------- */