Manual pages: mcmcdiffmceditmcview

root/tests/src/filemanager/examine_cd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_current_type
  2. panel_cd
  3. sync_tree
  4. START_TEST
  5. main

   1 /*
   2    src/filemanager - examine_cd() function testing
   3 
   4    Copyright (C) 2012-2025
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Andrew Borodin <aborodin@vmail.ru>, 2012, 2020
   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 "/src/filemanager"
  28 
  29 #include "tests/mctest.h"
  30 
  31 #include "src/filemanager/cd.c"
  32 
  33 /* --------------------------------------------------------------------------------------------- */
  34 
  35 WPanel *current_panel = NULL;
  36 
  37 panel_view_mode_t
  38 get_current_type (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  39 {
  40     return view_listing;
  41 }
  42 
  43 gboolean
  44 panel_cd (WPanel *panel, const vfs_path_t *new_dir_vpath, enum cd_enum cd_type)
     /* [previous][next][first][last][top][bottom][index][help]  */
  45 {
  46     (void) panel;
  47     (void) new_dir_vpath;
  48     (void) cd_type;
  49 
  50     return TRUE;
  51 }
  52 
  53 void
  54 sync_tree (const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
  55 {
  56     (void) vpath;
  57 }
  58 
  59 /* --------------------------------------------------------------------------------------------- */
  60 
  61 #define check_examine_cd(input, etalon)                                                            \
  62     {                                                                                              \
  63         result = examine_cd (input);                                                               \
  64         ck_assert_msg (strcmp (result->str, etalon) == 0,                                          \
  65                        "\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result->str,  \
  66                        etalon);                                                                    \
  67         g_string_free (result, TRUE);                                                              \
  68     }
  69 
  70 START_TEST (test_examine_cd)
     /* [previous][next][first][last][top][bottom][index][help]  */
  71 {
  72     GString *result;
  73 
  74     g_setenv ("AAA", "aaa", TRUE);
  75 
  76     check_examine_cd ("/test/path", "/test/path");
  77 
  78     check_examine_cd ("$AAA", "aaa");
  79     check_examine_cd ("${AAA}", "aaa");
  80     check_examine_cd ("$AAA/test", "aaa/test");
  81     check_examine_cd ("${AAA}/test", "aaa/test");
  82 
  83     check_examine_cd ("/$AAA", "/aaa");
  84     check_examine_cd ("/${AAA}", "/aaa");
  85     check_examine_cd ("/$AAA/test", "/aaa/test");
  86     check_examine_cd ("/${AAA}/test", "/aaa/test");
  87 
  88     check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
  89     check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
  90     check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
  91 
  92     check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
  93     check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
  94     check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
  95     check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
  96     check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
  97 
  98     check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
  99     check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
 100     check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
 101 
 102     check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
 103     check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
 104     check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
 105     check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
 106 }
 107 END_TEST
 108 
 109 /* --------------------------------------------------------------------------------------------- */
 110 
 111 int
 112 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 113 {
 114     TCase *tc_core;
 115 
 116     tc_core = tcase_create ("Core");
 117 
 118     // Add new tests here: ***************
 119     tcase_add_test (tc_core, test_examine_cd);
 120     // ***********************************
 121 
 122     return mctest_run_all (tc_core);
 123 }
 124 
 125 /* --------------------------------------------------------------------------------------------- */

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