src/strutil/xstrtol.c: sync with gnulib.
[midnight-commander.git] / tests / lib / search / regex_process_escape_sequence.c
blob1296d13977c901ea28105d6cd6d8d111ea8f9c33
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 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") */
35 /* *INDENT-OFF* */
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[] =
44 { /* 0. */
45 "{101}",
46 REPLACE_T_NO_TRANSFORM,
47 FALSE,
48 "A"
50 { /* 1. */
51 "x42",
52 REPLACE_T_NO_TRANSFORM,
53 FALSE,
54 "B"
56 { /* 2. */
57 "x{444}",
58 REPLACE_T_NO_TRANSFORM,
59 FALSE,
60 "D"
62 { /* 3. */
63 "x{444}",
64 REPLACE_T_NO_TRANSFORM,
65 TRUE,
66 "ф"
68 { /* 4. */
69 "n",
70 REPLACE_T_NO_TRANSFORM,
71 FALSE,
72 "\n"
74 { /* 5. */
75 "t",
76 REPLACE_T_NO_TRANSFORM,
77 FALSE,
78 "\t"
80 { /* 6. */
81 "v",
82 REPLACE_T_NO_TRANSFORM,
83 FALSE,
84 "\v"
86 { /* 7. */
87 "b",
88 REPLACE_T_NO_TRANSFORM,
89 FALSE,
90 "\b"
92 { /* 8. */
93 "r",
94 REPLACE_T_NO_TRANSFORM,
95 FALSE,
96 "\r"
98 { /* 9. */
99 "f",
100 REPLACE_T_NO_TRANSFORM,
101 FALSE,
102 "\f"
104 { /* 10. */
105 "a",
106 REPLACE_T_NO_TRANSFORM,
107 FALSE,
108 "\a"
111 /* *INDENT-ON* */
113 /* @Test(dataSource = "test_regex_process_escape_sequence_ds") */
114 /* *INDENT-OFF* */
115 START_PARAMETRIZED_TEST (test_regex_process_escape_sequence, test_regex_process_escape_sequence_ds)
116 /* *INDENT-ON* */
118 /* given */
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 ("");
125 /* when */
126 mc_search_regex__process_escape_sequence (actual_string, data->input_from, -1, &replace_flags,
127 data->input_use_utf);
129 /* then */
130 mctest_assert_str_eq (actual_string->str, data->expected_string);
132 g_string_free (actual_string, TRUE);
134 /* *INDENT-OFF* */
135 END_PARAMETRIZED_TEST
136 /* *INDENT-ON* */
138 /* --------------------------------------------------------------------------------------------- */
141 main (void)
143 TCase *tc_core;
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 /* --------------------------------------------------------------------------------------------- */