Ticket #4427: extfs: "Inconsistent archive" error for valid RPM.
[midnight-commander.git] / tests / lib / search / regex_multiline_str.c
blob36d8d8f931ca6cbbad74b3b2721e448403ebe705
1 /*
2 libmc - checks search functions
4 Copyright (C) 2022
5 Free Software Foundation, Inc.
7 Written by:
8 Steef Boerrigter <sxmboer@gmail.com>, 2022
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/search"
28 #include "tests/mctest.h"
30 #include "search.c" /* for testing static functions */
32 /* --------------------------------------------------------------------------------------------- */
34 /* @DataSource("test_regex_multiline_str_ds") */
35 /* *INDENT-OFF* */
36 static const struct test_regex_multiline_str_ds
38 const mc_search_type_t type;
39 const char *buffer;
40 const char *search_str;
41 const gboolean retval;
42 } test_regex_multiline_str_ds[] =
44 { /* 1. */
45 MC_SEARCH_T_NORMAL,
46 "abcdefgh",
47 "nope",
48 FALSE
50 { /* 2. */
51 MC_SEARCH_T_NORMAL,
52 "abcdefgh",
53 "def",
54 TRUE
56 { /* 3. */
57 MC_SEARCH_T_NORMAL,
58 "abcdefgh",
59 "z",
60 FALSE
62 { /* 4. */
63 MC_SEARCH_T_NORMAL,
64 "abcd \tefgh",
65 "\t ",
66 TRUE
68 { /* 5. multiline */
69 MC_SEARCH_T_NORMAL,
70 "abcd\ne\nfgh",
71 "\ne\nf",
72 TRUE
74 { /* 6. */
75 MC_SEARCH_T_NORMAL,
76 "abcd\nefgh",
77 "d\ne",
78 TRUE
80 { /* 7. mc-4.8.28 fails this edge condition */
81 MC_SEARCH_T_NORMAL,
82 "abcdefgh\n",
83 "\n",
84 TRUE
86 { /* 8. mc-4.8.28 fails this edge condition */
87 MC_SEARCH_T_NORMAL,
88 "abcdefgh\n",
89 "\n\n",
90 FALSE
92 { /* 9. regex including newline */
93 MC_SEARCH_T_REGEX,
94 "abcd\nefgh",
95 "abc[c-e]\nef",
96 TRUE
98 { /* 10. regex's newline support */
99 MC_SEARCH_T_REGEX,
100 "abcd\nefgh",
101 "abc[c-e]\\nef",
102 TRUE
105 /* *INDENT-ON* */
107 /* @Test(dataSource = "test_regex_multiline_str_ds") */
108 /* *INDENT-OFF* */
109 START_PARAMETRIZED_TEST (test_regex_multiline_str, test_regex_multiline_str_ds)
110 /* *INDENT-ON* */
112 /* given */
113 mc_search_t *s;
114 gboolean retval;
116 s = mc_search_new (data->buffer, NULL);
117 s->is_case_sensitive = FALSE;
118 s->search_type = data->type;
120 /* when */
121 retval = mc_search (data->search_str, DEFAULT_CHARSET, data->buffer, s->search_type);
123 /* then */
124 if (data->retval)
126 mctest_assert_true (retval);
128 else
130 mctest_assert_false (retval);
133 mc_search_free (s);
135 /* *INDENT-OFF* */
136 END_PARAMETRIZED_TEST
137 /* *INDENT-ON* */
139 /* --------------------------------------------------------------------------------------------- */
142 main (void)
144 TCase *tc_core;
146 tc_core = tcase_create ("Core");
148 /* Add new tests here: *************** */
149 mctest_add_parameterized_test (tc_core, test_regex_multiline_str, test_regex_multiline_str_ds);
150 /* *********************************** */
152 return mctest_run_all (tc_core);
155 /* --------------------------------------------------------------------------------------------- */