Hash :
e16c2f6a
Author :
Date :
2011-01-20T19:51:34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#include "test_lib.h"
#include "fileops.h"
static int ensure_normalized(const char *input_path, const char *expected_path)
{
int error = GIT_SUCCESS;
char buffer_out[GIT_PATH_MAX];
error = git_prettify_dir_path(buffer_out, input_path);
if (error < GIT_SUCCESS)
return error;
if (expected_path == NULL)
return error;
if (strcmp(buffer_out, expected_path))
error = GIT_ERROR;
return error;
}
BEGIN_TEST(path_prettifying)
must_pass(ensure_normalized("", ""));
must_pass(ensure_normalized(".", ""));
must_pass(ensure_normalized("./", ""));
must_pass(ensure_normalized("./.", ""));
must_fail(ensure_normalized("./..", NULL));
must_fail(ensure_normalized("../.", NULL));
must_fail(ensure_normalized("./.././/", NULL));
must_pass(ensure_normalized("dir/..", ""));
must_pass(ensure_normalized("dir/sub/../..", ""));
must_pass(ensure_normalized("dir/sub/..///..", ""));
must_pass(ensure_normalized("dir/sub///../..", ""));
must_pass(ensure_normalized("dir/sub///..///..", ""));
must_fail(ensure_normalized("dir/sub/../../..", NULL));
must_pass(ensure_normalized("dir", "dir/"));
must_pass(ensure_normalized("dir//", "dir/"));
must_pass(ensure_normalized("./dir", "dir/"));
must_pass(ensure_normalized("dir/.", "dir/"));
must_pass(ensure_normalized("dir///./", "dir/"));
must_pass(ensure_normalized("dir/sub/..", "dir/"));
must_pass(ensure_normalized("dir//sub/..", "dir/"));
must_pass(ensure_normalized("dir//sub/../", "dir/"));
must_pass(ensure_normalized("dir/sub/../", "dir/"));
must_pass(ensure_normalized("dir/sub/../.", "dir/"));
must_pass(ensure_normalized("dir/s1/../s2/", "dir/s2/"));
must_pass(ensure_normalized("d1/s1///s2/..//../s3/", "d1/s3/"));
must_pass(ensure_normalized("d1/s1//../s2/../../d2", "d2/"));
must_pass(ensure_normalized("dir/sub/../", "dir/"));
must_fail(ensure_normalized("....", NULL));
must_fail(ensure_normalized("...", NULL));
must_fail(ensure_normalized("./...", NULL));
must_fail(ensure_normalized("d1/...", NULL));
must_fail(ensure_normalized("d1/.../", NULL));
must_fail(ensure_normalized("d1/.../d2", NULL));
must_pass(ensure_normalized("/", "/"));
must_pass(ensure_normalized("//", "/"));
must_pass(ensure_normalized("///", "/"));
must_pass(ensure_normalized("/.", "/"));
must_pass(ensure_normalized("/./", "/"));
must_fail(ensure_normalized("/./..", NULL));
must_fail(ensure_normalized("/../.", NULL));
must_fail(ensure_normalized("/./.././/", NULL));
must_pass(ensure_normalized("/dir/..", "/"));
must_pass(ensure_normalized("/dir/sub/../..", "/"));
must_fail(ensure_normalized("/dir/sub/../../..", NULL));
must_pass(ensure_normalized("/dir", "/dir/"));
must_pass(ensure_normalized("/dir//", "/dir/"));
must_pass(ensure_normalized("/./dir", "/dir/"));
must_pass(ensure_normalized("/dir/.", "/dir/"));
must_pass(ensure_normalized("/dir///./", "/dir/"));
must_pass(ensure_normalized("/dir//sub/..", "/dir/"));
must_pass(ensure_normalized("/dir/sub/../", "/dir/"));
must_pass(ensure_normalized("//dir/sub/../.", "/dir/"));
must_pass(ensure_normalized("/dir/s1/../s2/", "/dir/s2/"));
must_pass(ensure_normalized("/d1/s1///s2/..//../s3/", "/d1/s3/"));
must_pass(ensure_normalized("/d1/s1//../s2/../../d2", "/d2/"));
must_fail(ensure_normalized("/....", NULL));
must_fail(ensure_normalized("/...", NULL));
must_fail(ensure_normalized("/./...", NULL));
must_fail(ensure_normalized("/d1/...", NULL));
must_fail(ensure_normalized("/d1/.../", NULL));
must_fail(ensure_normalized("/d1/.../d2", NULL));
END_TEST