static const char *link2;
static const char *link3;
-static void test_local_path() {
+static void test_local_path(void)
+{
const char *expected = t_strconcat(cwd, "/README.md", NULL);
const char *npath = NULL, *error = NULL;
test_assert(t_normpath_to("README.md", cwd, &npath, &error) == 0);
test_assert_strcmp(npath, expected);
}
-static void test_absolute_path_no_change(void) {
+static void test_absolute_path_no_change(void)
+{
const char *npath = NULL, *error = NULL;
test_assert(t_normpath_to("/", "/", &npath, &error) == 0);
test_assert_strcmp(npath, "/");
test_assert_strcmp(npath, cwd);
}
-static int path_height(const char* p) {
+static int path_height(const char *p)
+{
int n;
for (n = 0; *p != '\0'; ++p)
n += *p == '/';
return n;
}
-static void test_travel_to_root(void) {
+static void test_travel_to_root(void)
+{
int l = path_height(cwd);
const char *npath = cwd;
for (npath = cwd; l != 0; l--) {
test_assert_strcmp(npath, "/");
}
-static void test_extra_slashes(void) {
+static void test_extra_slashes(void)
+{
const char *npath = NULL, *error = NULL;
test_assert(t_normpath_to(".", cwd, &npath, &error) == 0);
test_assert_strcmp(npath, cwd);
test_assert_strcmp(npath, cwd);
}
-static void test_nonexistent_path(void) {
+static void test_nonexistent_path(void)
+{
const char *npath = NULL, *error = NULL;
const char *expected = t_strconcat(cwd, "/nonexistent", NULL);
test_assert(t_normpath_to("nonexistent", cwd, &npath, &error) == 0);
test_assert(error != NULL);
}
-static void test_relative_dotdot() {
+static void test_relative_dotdot(void)
+{
const char *rel_path = "../"TEMP_DIRNAME;
const char *npath = NULL, *error = NULL;
test_assert(t_normpath_to(rel_path, tmpdir, &npath, &error) == 0);
test_assert_strcmp(npath, cwd);
}
-static void test_link1() {
+static void test_link1(void)
+{
const char *npath = NULL, *error = NULL;
test_assert(t_realpath_to(link1, "/", &npath, &error) == 0);
test_assert_strcmp(npath, tmpdir);
}
-static void test_link_loop() {
+static void test_link_loop(void)
+{
const char *npath = NULL, *error = NULL;
errno = 0;
test_assert(t_realpath_to(link2, "/", &npath, &error) == -1);
test_assert(error != NULL);
}
-static void test_abspath_vs_normpath() {
+static void test_abspath_vs_normpath(void)
+{
const char *abs = t_abspath_to("../../bin", "/usr/lib/");
test_assert_strcmp(abs, "/usr/lib//../../bin");
test_assert_strcmp(norm, "/bin");
}
-static void test_link_alloc() {
+static void test_link_alloc(void)
+{
#define COMPONENT_COMPONENT "/component-component"
const char *o_tmpdir;
i_error("unlink_directory() failed: %s", error);
}
-static void test_init(void) {
+static void test_init(void)
+{
const char *error;
test_assert(t_get_working_dir(&cwd, &error) == 0);
tmpdir = t_strconcat(cwd, "/"TEMP_DIRNAME, NULL);
}
}
-void test_path_util(void) {
+void test_path_util(void)
+{
test_begin("test_path_util");
alarm(20);
test_init();