summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-09-22 23:24:30 -0400
committerCarlos Martín Nieto <cmn@dwim.me>2015-11-04 17:04:47 -0800
commit1a1d5758cbfab36612acf984bd48643d4a579040 (patch)
tree81c2d8578577107c6c299c3a1aa44e7b08bfeb35
parent80b4536b0be21073a18f0a1014a6345351caadf8 (diff)
downloadlibgit2-1a1d5758cbfab36612acf984bd48643d4a579040.tar.gz
win32: test checkout msg on long path err
-rw-r--r--tests/win32/longpath.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
new file mode 100644
index 000000000..4fe851c2a
--- /dev/null
+++ b/tests/win32/longpath.c
@@ -0,0 +1,62 @@
+#include "clar_libgit2.h"
+
+#include "git2/clone.h"
+#include "clone.h"
+#include "buffer.h"
+#include "fileops.h"
+
+static git_buf path = GIT_BUF_INIT;
+
+void test_win32_longpath__initialize(void)
+{
+#ifdef GIT_WIN32
+ const char *base = clar_sandbox_path();
+ size_t base_len = strlen(base);
+ size_t remain = MAX_PATH - base_len;
+ size_t i;
+
+ git_buf_clear(&path);
+ git_buf_puts(&path, base);
+ git_buf_putc(&path, '/');
+
+ cl_assert(remain < (MAX_PATH - 5));
+
+ for (i = 0; i < (remain - 5); i++)
+ git_buf_putc(&path, 'a');
+
+ printf("%s %" PRIuZ "\n", path.ptr, path.size);
+#endif
+}
+
+void test_win32_longpath__cleanup(void)
+{
+ git_buf_free(&path);
+}
+
+#ifdef GIT_WIN32
+void assert_name_too_long(void)
+{
+ const git_error *err;
+ size_t expected_len, actual_len;
+ const char *expected_msg;
+
+ err = giterr_last();
+ actual_len = strlen(err->message);
+
+ expected_msg = git_win32_get_error_message(ERROR_FILENAME_EXCED_RANGE);
+ expected_len = strlen(expected_msg);
+
+ /* check the suffix */
+ cl_assert_equal_s(expected_msg, err->message + (actual_len - expected_len));
+}
+#endif
+
+void test_win32_longpath__errmsg_on_checkout(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo;
+
+ cl_git_fail(git_clone(&repo, cl_fixture("testrepo.git"), path.ptr, NULL));
+ assert_name_too_long();
+#endif
+}