13 system("mkdir -p test_list_dir/nested/nested2");
14 system("mkdir -p test_list_dir/nested/nested3");
15 system("echo A > test_list_dir/A.txt");
16 system("echo A > test_list_dir/B.txt");
17 system("echo A > test_list_dir/nested/C.txt");
18 system("echo A > test_list_dir/nested/nested2/D.txt");
24 system("rm -rf test_list_dir");
28 true(G_GNUC_UNUSED
const gchar
* arg
)
33 START_TEST(test_get_file_list
)
35 GSList
*files
= get_file_list("test_list_dir", NULL
, NULL
, NULL
);
36 fail_unless(g_slist_length(files
) == 4, "expected %d, get %d", 4, g_slist_length(files
));
41 START_TEST(test_get_full_path
)
43 gchar
*newpath
= get_full_path("/home/yura/src/geanyprj/.geanyprj", "./abc.c");
44 fail_unless(strcmp(newpath
, "/home/yura/src/geanyprj/abc.c") == 0,
45 "expected %s, get %s", "/home/yura/src/geanyprj/abc.c", newpath
);
51 START_TEST(test_get_relative_path
)
53 gchar
*newpath
= get_relative_path("/home/yura/src/geanyprj/.geanyprj",
54 "/home/yura/src/geanyprj/src/a.c");
55 fail_unless(strcmp(newpath
, "src/a.c") == 0, "expected %s, get %s", "src/a.c", newpath
);
58 newpath
= get_relative_path("/home/yura/src/geanyprj/.geanyprj", "/home/yura/src/geanyprj");
59 fail_unless(strcmp(newpath
, "./") == 0, "expected %s, get %s", "./", newpath
);
65 START_TEST(test_find_file_path
)
67 fail_unless(find_file_path("insane_dir", "insane_file!!!!!!!!!!!!!!!2") == NULL
);
73 START_TEST(test_normpath
)
75 gchar
*newpath
= normpath("/a/b");
76 fail_unless(strcmp(newpath
, "/a/b") == 0, "expected %s, get %s", "/a/b", newpath
);
79 newpath
= normpath("./a/b");
80 fail_unless(strcmp(newpath
, "./a/b") == 0, "expected %s, get %s", "./a/b", newpath
);
83 newpath
= normpath("/a/./b");
84 fail_unless(strcmp(newpath
, "/a/b") == 0, "expected %s, get %s", "/a/b", newpath
);
87 newpath
= normpath("/a/.//b");
88 fail_unless(strcmp(newpath
, "/a/b") == 0, "expected %s, get %s", "/a/b", newpath
);
91 newpath
= normpath("c:\\a\\.\\b");
92 fail_unless(strcmp(newpath
, "c:/a/b") == 0, "expected %s, get %s", "c:/a/b", newpath
);
95 newpath
= normpath("/a/../b");
96 fail_unless(strcmp(newpath
, "/b") == 0, "expected %s, get %s", "/b", newpath
);
99 newpath
= normpath("../a");
100 fail_unless(strcmp(newpath
, "../a") == 0, "expected %s, get %s", "../a", newpath
);
103 newpath
= normpath("../a/..");
104 fail_unless(strcmp(newpath
, "..") == 0, "expected %s, get %s", "..", newpath
);
113 Suite
*s
= suite_create("Project");
114 TCase
*tc_core
= tcase_create("utils");
116 suite_add_tcase(s
, tc_core
);
117 tcase_add_test(tc_core
, test_get_full_path
);
118 tcase_add_test(tc_core
, test_get_relative_path
);
119 tcase_add_test(tc_core
, test_find_file_path
);
120 tcase_add_test(tc_core
, test_normpath
);
122 TCase
*tc_file
= tcase_create("file_utils");
123 suite_add_tcase(s
, tc_file
);
124 tcase_add_test(tc_file
, test_get_file_list
);
126 tcase_add_checked_fixture(tc_file
, file_setup
, file_teardown
);
134 Suite
*s
= my_suite();
135 SRunner
*sr
= srunner_create(s
);
136 srunner_run_all(sr
, CK_NORMAL
);
137 nf
= srunner_ntests_failed(sr
);
139 return (nf
== 0) ? EXIT_SUCCESS
: EXIT_FAILURE
;