Add more tests for VFS
[midnight-commander.git] / lib / tests / vfs / vfs_path_from_string.c
blob6af6f61183f2bf5a9945f6cf00a5a1073373830b
1 /* lib/vfs - get vfs_path_t from string
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/vfs"
25 #include <check.h>
28 #include "lib/global.h"
29 #include "lib/strutil.h"
30 #include "lib/vfs/xdirentry.h"
31 #include "lib/vfs/path.c" /* for testing static methods */
33 #include "src/vfs/local/local.c"
35 struct vfs_s_subclass test_subclass1, test_subclass2, test_subclass3;
36 struct vfs_class vfs_test_ops1, vfs_test_ops2, vfs_test_ops3;
38 static void
39 setup (void)
42 str_init_strings (NULL);
44 vfs_init ();
45 init_localfs ();
46 vfs_setup_work_dir ();
49 test_subclass1.flags = VFS_S_REMOTE;
50 vfs_s_init_class (&vfs_test_ops1, &test_subclass1);
52 vfs_test_ops1.name = "testfs1";
53 vfs_test_ops1.flags = VFSF_NOLINKS;
54 vfs_test_ops1.prefix = "test1:";
55 vfs_register_class (&vfs_test_ops1);
57 vfs_s_init_class (&vfs_test_ops2, &test_subclass2);
58 vfs_test_ops2.name = "testfs2";
59 vfs_test_ops2.prefix = "test2:";
60 vfs_register_class (&vfs_test_ops2);
62 vfs_s_init_class (&vfs_test_ops3, &test_subclass3);
63 vfs_test_ops3.name = "testfs3";
64 vfs_test_ops3.prefix = "test3:";
65 vfs_register_class (&vfs_test_ops3);
69 static void
70 teardown (void)
72 vfs_shut ();
75 /* --------------------------------------------------------------------------------------------- */
77 START_TEST (test_vfs_path_from_string)
79 vfs_path_t *vpath;
80 size_t vpath_len;
81 vpath = vfs_path_from_str ("/#test1://bla-bla/some/path/#test2://bla-bla/some/path#test3:/111/22/33");
83 vpath_len = vfs_path_length(vpath);
84 // fail_unless(vpath_len == 3, "vpath length should be 3 (actial: %d)",vpath_len);
85 vfs_path_free(vpath);
87 END_TEST
89 /* --------------------------------------------------------------------------------------------- */
91 int
92 main (void)
94 int number_failed;
96 Suite *s = suite_create (TEST_SUITE_NAME);
97 TCase *tc_core = tcase_create ("Core");
98 SRunner *sr;
100 tcase_add_checked_fixture (tc_core, setup, teardown);
102 /* Add new tests here: *************** */
103 tcase_add_test (tc_core, test_vfs_path_from_string);
104 /* *********************************** */
106 suite_add_tcase (s, tc_core);
107 sr = srunner_create (s);
108 srunner_set_log (sr, "get_vfs_class.log");
109 srunner_run_all (sr, CK_NORMAL);
110 number_failed = srunner_ntests_failed (sr);
111 srunner_free (sr);
112 return (number_failed == 0) ? 0 : 1;
115 /* --------------------------------------------------------------------------------------------- */