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. do_cd
  3. quiet_quit_cmd
  4. expand_format
  5. init_subshell
  6. do_load_prompt
  7. shell_execute
  8. sync_tree
  9. setup
  10. teardown
  11. START_TEST
  12. main

   1 /*
   2    src/filemanager - examine_cd() function testing
   3 
   4    Copyright (C) 2012-2018
   5    Free Software Foundation, Inc.
   6 
   7    Written by:
   8    Andrew Borodin <aborodin@vmail.ru>, 2012
   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 "lib/vfs/path.h"
  34 #include "src/filemanager/layout.h"
  35 #include "src/filemanager/midnight.h"
  36 #include "src/filemanager/tree.h"
  37 #ifdef ENABLE_SUBSHELL
  38 #include "src/subshell/subshell.h"
  39 #endif /* ENABLE_SUBSHELL */
  40 
  41 #include "src/filemanager/command.c"
  42 
  43 /* --------------------------------------------------------------------------------------------- */
  44 
  45 gboolean command_prompt = FALSE;
  46 #ifdef ENABLE_SUBSHELL
  47 enum subshell_state_enum subshell_state = INACTIVE;
  48 #endif /* ENABLE_SUBSHELL */
  49 int quit = 0;
  50 WPanel *current_panel = NULL;
  51 
  52 panel_view_mode_t
  53 get_current_type (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  54 {
  55     return view_listing;
  56 }
  57 
  58 gboolean
  59 do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum cd_type)
     /* [previous][next][first][last][top][bottom][index][help]  */
  60 {
  61     (void) new_dir_vpath;
  62     (void) cd_type;
  63 
  64     return TRUE;
  65 }
  66 
  67 gboolean
  68 quiet_quit_cmd (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  69 {
  70     return FALSE;
  71 }
  72 
  73 char *
  74 expand_format (const WEdit * edit_widget, char c, gboolean do_quote)
     /* [previous][next][first][last][top][bottom][index][help]  */
  75 {
  76     (void) edit_widget;
  77     (void) c;
  78     (void) do_quote;
  79 
  80     return NULL;
  81 }
  82 
  83 #ifdef ENABLE_SUBSHELL
  84 void
  85 init_subshell (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  86 {
  87 }
  88 
  89 gboolean
  90 do_load_prompt (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
  91 {
  92     return TRUE;
  93 }
  94 #endif /* ENABLE_SUBSHELL */
  95 
  96 void
  97 shell_execute (const char *command, int flags)
     /* [previous][next][first][last][top][bottom][index][help]  */
  98 {
  99     (void) command;
 100     (void) flags;
 101 }
 102 
 103 void
 104 sync_tree (const vfs_path_t * vpath)
     /* [previous][next][first][last][top][bottom][index][help]  */
 105 {
 106     (void) vpath;
 107 }
 108 
 109 /* --------------------------------------------------------------------------------------------- */
 110 
 111 static void
 112 setup (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 113 {
 114 }
 115 
 116 static void
 117 teardown (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 118 {
 119 }
 120 
 121 /* --------------------------------------------------------------------------------------------- */
 122 #define check_examine_cd(input, etalon) \
 123 { \
 124     result = examine_cd (input); \
 125     fail_unless (strcmp (result, etalon) == 0, \
 126     "\ninput (%s)\nactial (%s) not equal to\netalon (%s)", input, result, etalon); \
 127     g_free (result); \
 128 }
 129 
 130 /* *INDENT-OFF* */
 131 START_TEST (test_examine_cd)
     /* [previous][next][first][last][top][bottom][index][help]  */
 132 /* *INDENT-ON* */
 133 {
 134     char *result;
 135 
 136     g_setenv ("AAA", "aaa", TRUE);
 137 
 138     check_examine_cd ("/test/path", "/test/path");
 139 
 140     check_examine_cd ("/test/path/$AAA", "/test/path/aaa");
 141     check_examine_cd ("/test/path/$AAA/test2", "/test/path/aaa/test2");
 142     check_examine_cd ("/test/path/test1$AAA/test2", "/test/path/test1aaa/test2");
 143 
 144     check_examine_cd ("/test/path/${AAA}", "/test/path/aaa");
 145     check_examine_cd ("/test/path/${AAA}/test2", "/test/path/aaa/test2");
 146     check_examine_cd ("/test/path/${AAA}test2", "/test/path/aaatest2");
 147     check_examine_cd ("/test/path/test1${AAA}", "/test/path/test1aaa");
 148     check_examine_cd ("/test/path/test1${AAA}test2", "/test/path/test1aaatest2");
 149 
 150     check_examine_cd ("/test/path/\\$AAA", "/test/path/$AAA");
 151     check_examine_cd ("/test/path/\\$AAA/test2", "/test/path/$AAA/test2");
 152     check_examine_cd ("/test/path/test1\\$AAA", "/test/path/test1$AAA");
 153 
 154     check_examine_cd ("/test/path/\\${AAA}", "/test/path/${AAA}");
 155     check_examine_cd ("/test/path/\\${AAA}/test2", "/test/path/${AAA}/test2");
 156     check_examine_cd ("/test/path/\\${AAA}test2", "/test/path/${AAA}test2");
 157     check_examine_cd ("/test/path/test1\\${AAA}test2", "/test/path/test1${AAA}test2");
 158 }
 159 /* *INDENT-OFF* */
 160 END_TEST
 161 /* *INDENT-ON* */
 162 
 163 /* --------------------------------------------------------------------------------------------- */
 164 
 165 int
 166 main (void)
     /* [previous][next][first][last][top][bottom][index][help]  */
 167 {
 168     int number_failed;
 169 
 170     Suite *s = suite_create (TEST_SUITE_NAME);
 171     TCase *tc_core = tcase_create ("Core");
 172     SRunner *sr;
 173 
 174     tcase_add_checked_fixture (tc_core, setup, teardown);
 175 
 176     /* Add new tests here: *************** */
 177     tcase_add_test (tc_core, test_examine_cd);
 178     /* *********************************** */
 179 
 180     suite_add_tcase (s, tc_core);
 181     sr = srunner_create (s);
 182     srunner_set_log (sr, "examine_cd.log");
 183     srunner_run_all (sr, CK_ENV);
 184     number_failed = srunner_ntests_failed (sr);
 185     srunner_free (sr);
 186 
 187     return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 188 }
 189 
 190 /* --------------------------------------------------------------------------------------------- */

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