Manual pages: mcmcdiffmceditmcview

root/tests/lib/x_basename.c

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

DEFINITIONS

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

   1 /*
   2    lib - x_basename() function testing
   3 
   4    Copyright (C) 2011-2025
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Slava Zanko <slavazanko@gmail.com>, 2011, 2013
   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 <https://www.gnu.org/licenses/>.
  24  */
  25 
  26 #define TEST_SUITE_NAME "/lib"
  27 
  28 #include "tests/mctest.h"
  29 
  30 #include "lib/strutil.h"
  31 #include "lib/util.h"
  32 
  33 /* --------------------------------------------------------------------------------------------- */
  34 
  35 /* @DataSource("test_x_basename_ds") */
  36 static const struct test_x_basename_ds
  37 {
  38     const char *input_value;
  39     const char *expected_result;
  40 } test_x_basename_ds[] = {
  41     {
  42         "/test/path/test2/path2",
  43         "path2",
  44     },
  45     {
  46         "/test/path/test2/path2#vfsprefix",
  47         "path2#vfsprefix",
  48     },
  49     {
  50         "/test/path/test2/path2/vfsprefix://",
  51         "path2/vfsprefix://",
  52     },
  53     {
  54         "/test/path/test2/path2/vfsprefix://subdir",
  55         "subdir",
  56     },
  57     {
  58         "/test/path/test2/path2/vfsprefix://subdir/",
  59         "subdir/",
  60     },
  61     {
  62         "/test/path/test2/path2/vfsprefix://subdir/subdir2",
  63         "subdir2",
  64     },
  65     {
  66         "/test/path/test2/path2/vfsprefix:///",
  67         "/",
  68     },
  69 };
  70 
  71 /* @Test(dataSource = "test_x_basename_ds") */
  72 START_PARAMETRIZED_TEST (test_x_basename, test_x_basename_ds)
     /* [previous][next][first][last][top][bottom][index][help]  */
  73 {
  74     // given
  75     const char *actual_result;
  76 
  77     // when
  78     actual_result = x_basename (data->input_value);
  79 
  80     // then
  81     mctest_assert_str_eq (actual_result, data->expected_result);
  82 }
  83 END_PARAMETRIZED_TEST
  84 
  85 /* --------------------------------------------------------------------------------------------- */
  86 
  87 int
  88 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  89 {
  90     TCase *tc_core;
  91 
  92     tc_core = tcase_create ("Core");
  93 
  94     // Add new tests here: ***************
  95     mctest_add_parameterized_test (tc_core, test_x_basename, test_x_basename_ds);
  96     // ***********************************
  97 
  98     return mctest_run_all (tc_core);
  99 }
 100 
 101 /* --------------------------------------------------------------------------------------------- */

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