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-2024
   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 <http://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, etalon); \
  80     g_string_free (result, TRUE); \
  81 }
  82 
  83 /* *INDENT-OFF* */
  84 START_TEST (test_examine_cd)
     /* [previous][next][first][last][top][bottom][index][help]  */
  85 /* *INDENT-ON* */
  86 {
  87     GString *result;
  88 
  89     g_setenv ("AAA", "aaa", TRUE);
  90 
  91     check_examine_cd ("/test/path", "/test/path");
  92 
  93     check_examine_cd ("$AAA", "aaa");
  94     check_examine_cd ("${AAA}", "aaa");
  95     check_examine_cd ("$AAA/test", "aaa/test");
  96     check_examine_cd ("${AAA}/test", "aaa/test");
  97 
  98     check_examine_cd ("/$AAA", "/aaa");
  99     check_examine_cd ("/${AAA}", "/aaa");
 100     check_examine_cd ("/$AAA/test", "/aaa/test");
 101     check_examine_cd ("/${AAA}/test", "/aaa/test");
 102 
 103     check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
 104     check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
 105     check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
 106 
 107     check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
 108     check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
 109     check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
 110     check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
 111     check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
 112 
 113     check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
 114     check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
 115     check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
 116 
 117     check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
 118     check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
 119     check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
 120     check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
 121 }
 122 /* *INDENT-OFF* */
 123 END_TEST
 124 /* *INDENT-ON* */
 125 
 126 /* --------------------------------------------------------------------------------------------- */
 127 
 128 int
 129 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 130 {
 131     TCase *tc_core;
 132 
 133     tc_core = tcase_create ("Core");
 134 
 135     tcase_add_checked_fixture (tc_core, setup, teardown);
 136 
 137     /* Add new tests here: *************** */
 138     tcase_add_test (tc_core, test_examine_cd);
 139     /* *********************************** */
 140 
 141     return mctest_run_all (tc_core);
 142 }
 143 
 144 /* --------------------------------------------------------------------------------------------- */

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