root/tests/src/filemanager/filegui_is_wildcarded.c

/* [previous][next][first][last][top][bottom][index][help]  */

DEFINITIONS

This source file includes following definitions.
  1. setup
  2. teardown
  3. START_PARAMETRIZED_TEST
  4. main

   1 /*
   2    src/filemanager - tests for is_wildcarded() function
   3 
   4    Copyright (C) 2011-2024
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Slava Zanko <slavazanko@gmail.com>, 2015
   9 
  10    This file is part of the Midnight Commander.
  11 
  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.
  16 
  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.
  21 
  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/>.
  24  */
  25 
  26 #define TEST_SUITE_NAME "/src/filemanager"
  27 
  28 #include "tests/mctest.h"
  29 
  30 #include "src/vfs/local/local.c"
  31 
  32 #include "src/filemanager/filegui.c"
  33 
  34 
  35 /* --------------------------------------------------------------------------------------------- */
  36 
  37 /* @Before */
  38 static void
  39 setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  40 {
  41     str_init_strings (NULL);
  42 
  43     vfs_init ();
  44     vfs_init_localfs ();
  45     vfs_setup_work_dir ();
  46 }
  47 
  48 /* --------------------------------------------------------------------------------------------- */
  49 
  50 /* @After */
  51 static void
  52 teardown (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  53 {
  54     vfs_shut ();
  55     str_uninit_strings ();
  56 }
  57 
  58 /* --------------------------------------------------------------------------------------------- */
  59 
  60 /* @DataSource("test_is_wildcarded_ds") */
  61 /* *INDENT-OFF* */
  62 static const struct test_is_wildcarded_ds
  63 {
  64     const char *input_value;
  65     gboolean expected_result;
  66 } test_is_wildcarded_ds[] =
  67 {
  68     { /* 0 */
  69         "blabla",
  70         FALSE
  71     },
  72     { /* 1 */
  73         "bla?bla",
  74         TRUE
  75     },
  76     { /* 2 */
  77         "bla*bla",
  78         TRUE
  79     },
  80     { /* 3 */
  81         "bla\\*bla",
  82         FALSE
  83     },
  84 
  85     { /* 4 */
  86         "bla\\\\*bla",
  87         TRUE
  88     },
  89     { /* 5 */
  90         "bla\\1bla",
  91         TRUE
  92     },
  93     { /* 6 */
  94         "bla\\\\1bla",
  95         FALSE
  96     },
  97     { /* 7 */
  98         "bla\\\t\\\\1bla",
  99         FALSE
 100     },
 101     { /* 8 */
 102         "bla\\\t\\\\\\1bla",
 103         TRUE
 104     },
 105     { /* 9 */
 106         "bla\\9bla",
 107         TRUE
 108     },
 109     { /* 10 */
 110         "blabla\\",
 111         FALSE
 112     },
 113     { /* 11 */
 114         "blab\\?la",
 115         FALSE
 116     },
 117     { /* 12 */
 118         "blab\\\\?la",
 119         TRUE
 120     },
 121 };
 122 /* *INDENT-ON* */
 123 
 124 /* @Test(dataSource = "test_is_wildcarded_ds") */
 125 /* *INDENT-OFF* */
 126 START_PARAMETRIZED_TEST (test_is_wildcarded, test_is_wildcarded_ds)
     /* [previous][next][first][last][top][bottom][index][help]  */
 127 /* *INDENT-ON* */
 128 {
 129     /* given */
 130     gboolean actual_result;
 131 
 132     /* when */
 133     actual_result = is_wildcarded (data->input_value);
 134     /* then */
 135     ck_assert_int_eq (actual_result, data->expected_result);
 136 }
 137 /* *INDENT-OFF* */
 138 END_PARAMETRIZED_TEST
 139 /* *INDENT-ON* */
 140 
 141 /* --------------------------------------------------------------------------------------------- */
 142 
 143 int
 144 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 145 {
 146     TCase *tc_core;
 147 
 148     tc_core = tcase_create ("Core");
 149 
 150     tcase_add_checked_fixture (tc_core, setup, teardown);
 151 
 152     /* Add new tests here: *************** */
 153     mctest_add_parameterized_test (tc_core, test_is_wildcarded, test_is_wildcarded_ds);
 154     /* *********************************** */
 155 
 156     return mctest_run_all (tc_core);
 157 }
 158 
 159 /* --------------------------------------------------------------------------------------------- */

/* [previous][next][first][last][top][bottom][index][help]  */