root/tests/lib/search/translate_replace_glob_to_regex.c

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

DEFINITIONS

This source file includes following definitions.
  1. START_PARAMETRIZED_TEST
  2. main

   1 /*
   2    libmc - checks for processing esc sequences in replace string
   3 
   4    Copyright (C) 2011-2025
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Andrew Borodin <aborodin@vmail.ru>, 2011
   9    Slava Zanko <slavazanko@gmail.com>, 2013
  10 
  11    This file is part of the Midnight Commander.
  12 
  13    The Midnight Commander is free software: you can redistribute it
  14    and/or modify it under the terms of the GNU General Public License as
  15    published by the Free Software Foundation, either version 3 of the License,
  16    or (at your option) any later version.
  17 
  18    The Midnight Commander is distributed in the hope that it will be useful,
  19    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21    GNU General Public License for more details.
  22 
  23    You should have received a copy of the GNU General Public License
  24    along with this program.  If not, see <https://www.gnu.org/licenses/>.
  25  */
  26 
  27 #define TEST_SUITE_NAME "lib/search/glob"
  28 
  29 #include "tests/mctest.h"
  30 
  31 #include "glob.c"  // for testing static functions
  32 
  33 /* --------------------------------------------------------------------------------------------- */
  34 
  35 /* @DataSource("test_translate_replace_glob_to_regex_ds") */
  36 static const struct test_translate_replace_glob_to_regex_ds
  37 {
  38     const char *input_value;
  39     const char *expected_result;
  40 } test_translate_replace_glob_to_regex_ds[] = {
  41     { "a&a?a", "a\\&a\\1a" },
  42     { "a\\&a?a", "a\\&a\\1a" },
  43     { "a&a\\?a", "a\\&a\\?a" },
  44     { "a\\&a\\?a", "a\\&a\\?a" },
  45 };
  46 
  47 /* @Test(dataSource = "test_translate_replace_glob_to_regex_ds") */
  48 START_PARAMETRIZED_TEST (test_translate_replace_glob_to_regex,
     /* [previous][next][first][last][top][bottom][index][help]  */
  49                          test_translate_replace_glob_to_regex_ds)
  50 {
  51     // given
  52     GString *dest_str;
  53 
  54     // when
  55     dest_str = mc_search__translate_replace_glob_to_regex (data->input_value);
  56 
  57     // then
  58     mctest_assert_str_eq (dest_str->str, data->expected_result);
  59     g_string_free (dest_str, TRUE);
  60 }
  61 END_PARAMETRIZED_TEST
  62 
  63 /* --------------------------------------------------------------------------------------------- */
  64 
  65 int
  66 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  67 {
  68     TCase *tc_core;
  69 
  70     tc_core = tcase_create ("Core");
  71 
  72     // Add new tests here: ***************
  73     mctest_add_parameterized_test (tc_core, test_translate_replace_glob_to_regex,
  74                                    test_translate_replace_glob_to_regex_ds);
  75     // ***********************************
  76 
  77     return mctest_run_all (tc_core);
  78 }
  79 
  80 /* --------------------------------------------------------------------------------------------- */

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