1 /* lib/vfs - mc_build_filename() function testing
3 Copyright (C) 2011 Free Software Foundation, Inc.
6 Slava Zanko <slavazanko@gmail.com>, 2011
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public License
10 as published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #define TEST_SUITE_NAME "/lib"
29 #include "lib/global.h"
30 #include "lib/strutil.h"
44 /* --------------------------------------------------------------------------------------------- */
45 #define check_mc_build_filename( inargs, etalon ) \
47 result = mc_build_filename inargs; \
48 fail_unless( strcmp (result, etalon) == 0, \
49 "\nactial (%s) not equal to\netalon (%s)", result, etalon); \
53 START_TEST (test_mc_build_filename
)
57 check_mc_build_filename(("test", "path", NULL
), "/test/path");
59 check_mc_build_filename(("/test", "path/", NULL
), "/test/path");
61 check_mc_build_filename(("/test", "pa/th", NULL
), "/test/pa/th");
63 check_mc_build_filename(("/test", "#vfsprefix:", "path ", NULL
), "/test/#vfsprefix:/path ");
65 check_mc_build_filename(("/test", "vfsprefix://", "path ", NULL
), "/test/vfsprefix://path ");
67 check_mc_build_filename(("/test", "vfs/../prefix:///", "p\\///ath", NULL
), "/test/prefix://p\\/ath");
69 check_mc_build_filename(("/test", "path", "..", "/test", "path/", NULL
), "/test/test/path");
74 /* --------------------------------------------------------------------------------------------- */
81 Suite
*s
= suite_create (TEST_SUITE_NAME
);
82 TCase
*tc_core
= tcase_create ("Core");
85 tcase_add_checked_fixture (tc_core
, setup
, teardown
);
87 /* Add new tests here: *************** */
88 tcase_add_test (tc_core
, test_mc_build_filename
);
89 /* *********************************** */
91 suite_add_tcase (s
, tc_core
);
92 sr
= srunner_create (s
);
93 srunner_set_log (sr
, "mc_build_filename.log");
94 srunner_run_all (sr
, CK_NORMAL
);
95 number_failed
= srunner_ntests_failed (sr
);
97 return (number_failed
== 0) ? 0 : 1;
100 /* --------------------------------------------------------------------------------------------- */