Added function mc_build_filename() for processing URL-paths as well
[midnight-commander.git] / lib / tests / mc_build_filename.c
blobe9568ce30b85ac081f9b30d1a13351032a22f03e
1 /* lib/vfs - mc_build_filename() function testing
3 Copyright (C) 2011 Free Software Foundation, Inc.
5 Written by:
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"
25 #include <check.h>
27 #include <stdio.h>
29 #include "lib/global.h"
30 #include "lib/strutil.h"
31 #include "lib/util.h"
34 static void
35 setup (void)
39 static void
40 teardown (void)
44 /* --------------------------------------------------------------------------------------------- */
45 #define check_mc_build_filename( inargs, etalon ) \
46 { \
47 result = mc_build_filename inargs; \
48 fail_unless( strcmp (result, etalon) == 0, \
49 "\nactial (%s) not equal to\netalon (%s)", result, etalon); \
50 g_free (result); \
53 START_TEST (test_mc_build_filename)
55 char *result;
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");
72 END_TEST
74 /* --------------------------------------------------------------------------------------------- */
76 int
77 main (void)
79 int number_failed;
81 Suite *s = suite_create (TEST_SUITE_NAME);
82 TCase *tc_core = tcase_create ("Core");
83 SRunner *sr;
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);
96 srunner_free (sr);
97 return (number_failed == 0) ? 0 : 1;
100 /* --------------------------------------------------------------------------------------------- */