root/tests/lib/x_basename.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    lib - x_basename() function testing
   3 
   4    Copyright (C) 2011-2018
   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 <http://www.gnu.org/licenses/>.
  24  */
  25 
  26 #define TEST_SUITE_NAME "/lib"
  27 
  28 #include "tests/mctest.h"
  29 
  30 #include <stdio.h>
  31 
  32 #include "lib/strutil.h"
  33 #include "lib/util.h"
  34 
  35 /* --------------------------------------------------------------------------------------------- */
  36 
  37 /* @Before */
  38 static void
  39 setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  40 {
  41 }
  42 
  43 /* --------------------------------------------------------------------------------------------- */
  44 
  45 /* @After */
  46 static void
  47 teardown (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  48 {
  49 }
  50 
  51 /* --------------------------------------------------------------------------------------------- */
  52 
  53 /* @DataSource("test_x_basename_ds") */
  54 /* *INDENT-OFF* */
  55 static const struct test_x_basename_ds
  56 {
  57     const char *input_value;
  58     const char *expected_result;
  59 } test_x_basename_ds[] =
  60 {
  61     {
  62         "/test/path/test2/path2",
  63         "path2"
  64     },
  65     {
  66         "/test/path/test2/path2#vfsprefix",
  67         "path2#vfsprefix"
  68     },
  69     {
  70         "/test/path/test2/path2/vfsprefix://",
  71         "path2/vfsprefix://"
  72     },
  73     {
  74         "/test/path/test2/path2/vfsprefix://subdir",
  75         "subdir"
  76     },
  77     {
  78         "/test/path/test2/path2/vfsprefix://subdir/",
  79         "subdir/"
  80     },
  81     {
  82         "/test/path/test2/path2/vfsprefix://subdir/subdir2",
  83         "subdir2"
  84     },
  85     {
  86         "/test/path/test2/path2/vfsprefix:///",
  87         "/"
  88     },
  89 };
  90 /* *INDENT-ON* */
  91 
  92 /* @Test(dataSource = "test_x_basename_ds") */
  93 /* *INDENT-OFF* */
  94 START_PARAMETRIZED_TEST (test_x_basename, test_x_basename_ds)
     /* [previous][next][first][last][top][bottom][index][help]  */
  95 /* *INDENT-ON* */
  96 {
  97     /* given */
  98     const char *actual_result;
  99 
 100     /* when */
 101     actual_result = x_basename (data->input_value);
 102 
 103     /* then */
 104     mctest_assert_str_eq (actual_result, data->expected_result);
 105 }
 106 /* *INDENT-OFF* */
 107 END_PARAMETRIZED_TEST
 108 /* *INDENT-ON* */
 109 
 110 /* --------------------------------------------------------------------------------------------- */
 111 
 112 int
 113 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 114 {
 115     int number_failed;
 116 
 117     Suite *s = suite_create (TEST_SUITE_NAME);
 118     TCase *tc_core = tcase_create ("Core");
 119     SRunner *sr;
 120 
 121     tcase_add_checked_fixture (tc_core, setup, teardown);
 122 
 123     /* Add new tests here: *************** */
 124     mctest_add_parameterized_test (tc_core, test_x_basename, test_x_basename_ds);
 125     /* *********************************** */
 126 
 127     suite_add_tcase (s, tc_core);
 128     sr = srunner_create (s);
 129     srunner_set_log (sr, "x_basename.log");
 130     srunner_run_all (sr, CK_ENV);
 131     number_failed = srunner_ntests_failed (sr);
 132     srunner_free (sr);
 133     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 134 }
 135 
 136 /* --------------------------------------------------------------------------------------------- */

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