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. setup
  5. teardown
  6. START_TEST
  7. 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 <stdio.h>
  32 
  33 #include "src/filemanager/cd.c"
  34 
  35 /* --------------------------------------------------------------------------------------------- */
  36 
  37 WPanel *current_panel = NULL;
  38 
  39 panel_view_mode_t
  40 get_current_type (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  41 {
  42     return view_listing;
  43 }
  44 
  45 gboolean
  46 panel_cd (WPanel *panel, const vfs_path_t *new_dir_vpath, enum cd_enum cd_type)
     /* [previous][next][first][last][top][bottom][index][help]  */
  47 {
  48     (void) panel;
  49     (void) new_dir_vpath;
  50     (void) cd_type;
  51 
  52     return TRUE;
  53 }
  54 
  55 void
  56 sync_tree (const vfs_path_t *vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
  57 {
  58     (void) vpath;
  59 }
  60 
  61 /* --------------------------------------------------------------------------------------------- */
  62 
  63 static void
  64 setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  65 {
  66 }
  67 
  68 static void
  69 teardown (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  70 {
  71 }
  72 
  73 /* --------------------------------------------------------------------------------------------- */
  74 
  75 #define check_examine_cd(input, etalon)                                                            \
  76     {                                                                                              \
  77         result = examine_cd (input);                                                               \
  78         ck_assert_msg (strcmp (result->str, etalon) == 0,                                          \
  79                        "\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result->str,  \
  80                        etalon);                                                                    \
  81         g_string_free (result, TRUE);                                                              \
  82     }
  83 
  84 START_TEST (test_examine_cd)
     /* [previous][next][first][last][top][bottom][index][help]  */
  85 {
  86     GString *result;
  87 
  88     g_setenv ("AAA", "aaa", TRUE);
  89 
  90     check_examine_cd ("/test/path", "/test/path");
  91 
  92     check_examine_cd ("$AAA", "aaa");
  93     check_examine_cd ("${AAA}", "aaa");
  94     check_examine_cd ("$AAA/test", "aaa/test");
  95     check_examine_cd ("${AAA}/test", "aaa/test");
  96 
  97     check_examine_cd ("/$AAA", "/aaa");
  98     check_examine_cd ("/${AAA}", "/aaa");
  99     check_examine_cd ("/$AAA/test", "/aaa/test");
 100     check_examine_cd ("/${AAA}/test", "/aaa/test");
 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/test1$AAA/test2", "/test/path/test1aaa/test2");
 105 
 106     check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
 107     check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
 108     check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
 109     check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
 110     check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
 111 
 112     check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
 113     check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
 114     check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
 115 
 116     check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
 117     check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
 118     check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
 119     check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
 120 }
 121 END_TEST
 122 
 123 /* --------------------------------------------------------------------------------------------- */
 124 
 125 int
 126 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 127 {
 128     TCase *tc_core;
 129 
 130     tc_core = tcase_create ("Core");
 131 
 132     tcase_add_checked_fixture (tc_core, setup, teardown);
 133 
 134     // Add new tests here: ***************
 135     tcase_add_test (tc_core, test_examine_cd);
 136     // ***********************************
 137 
 138     return mctest_run_all (tc_core);
 139 }
 140 
 141 /* --------------------------------------------------------------------------------------------- */

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