(mc_search_run): document the return value.
[midnight-commander.git] / tests / src / filemanager / filegui_is_wildcarded.c
blob434bb9388e5d3a7dadc84c8ef6fbe3ed7559040d
1 /*
2 src/filemanager - tests for is_wildcarded() function
4 Copyright (C) 2011-2016
5 Free Software Foundation, Inc.
7 Written by:
8 Slava Zanko <slavazanko@gmail.com>, 2015
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 "/src/filemanager"
28 #include "tests/mctest.h"
30 #include "src/vfs/local/local.c"
32 #include "src/filemanager/filegui.c"
35 /* --------------------------------------------------------------------------------------------- */
37 /* @Before */
38 static void
39 setup (void)
41 str_init_strings (NULL);
43 vfs_init ();
44 init_localfs ();
45 vfs_setup_work_dir ();
48 /* --------------------------------------------------------------------------------------------- */
50 /* @After */
51 static void
52 teardown (void)
54 vfs_shut ();
55 str_uninit_strings ();
58 /* --------------------------------------------------------------------------------------------- */
60 /* @DataSource("test_is_wildcarded_ds") */
61 /* *INDENT-OFF* */
62 static const struct test_is_wildcarded_ds
64 const char *input_value;
65 gboolean expected_result;
66 } test_is_wildcarded_ds[] =
68 { /* 0 */
69 "blabla",
70 FALSE
72 { /* 1 */
73 "bla?bla",
74 TRUE
76 { /* 2 */
77 "bla*bla",
78 TRUE
80 { /* 3 */
81 "bla\\*bla",
82 FALSE
85 { /* 4 */
86 "bla\\\\*bla",
87 TRUE
89 { /* 5 */
90 "bla\\1bla",
91 TRUE
93 { /* 6 */
94 "bla\\\\1bla",
95 FALSE
97 { /* 7 */
98 "bla\\\t\\\\1bla",
99 FALSE
101 { /* 8 */
102 "bla\\\t\\\\\\1bla",
103 TRUE
105 { /* 9 */
106 "bla\\9bla",
107 TRUE
109 { /* 10 */
110 "blabla\\",
111 FALSE
113 { /* 11 */
114 "blab\\?la",
115 FALSE
117 { /* 12 */
118 "blab\\\\?la",
119 TRUE
122 /* *INDENT-ON* */
124 /* @Test(dataSource = "test_is_wildcarded_ds") */
125 /* *INDENT-OFF* */
126 START_PARAMETRIZED_TEST (test_is_wildcarded, test_is_wildcarded_ds)
127 /* *INDENT-ON* */
129 /* given */
130 gboolean actual_result;
132 /* when */
133 actual_result = is_wildcarded (data->input_value);
134 /* then */
135 mctest_assert_int_eq (actual_result, data->expected_result);
137 /* *INDENT-OFF* */
138 END_PARAMETRIZED_TEST
139 /* *INDENT-ON* */
141 /* --------------------------------------------------------------------------------------------- */
144 main (void)
146 int number_failed;
148 Suite *s = suite_create (TEST_SUITE_NAME);
149 TCase *tc_core = tcase_create ("Core");
150 SRunner *sr;
152 tcase_add_checked_fixture (tc_core, setup, teardown);
154 /* Add new tests here: *************** */
155 mctest_add_parameterized_test (tc_core, test_is_wildcarded, test_is_wildcarded_ds);
156 /* *********************************** */
158 suite_add_tcase (s, tc_core);
159 sr = srunner_create (s);
160 srunner_set_log (sr, "filegui_is_wildcarded.log");
161 srunner_run_all (sr, CK_ENV);
162 number_failed = srunner_ntests_failed (sr);
163 srunner_free (sr);
164 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
167 /* --------------------------------------------------------------------------------------------- */