aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-11-16 09:24:10 -0500
committerJames McCoy <jamessan@jamessan.com>2017-06-04 22:12:13 -0400
commit953f26bace041f481e79b67b64401aa07259055c (patch)
treeaf054b1eac1ffaefa9643deca7100ecb74f89138 /src/nvim/testdir
parent018383096c40aca83a76e1ae2a3ba8c5aac9b9af (diff)
downloadrneovim-953f26bace041f481e79b67b64401aa07259055c.tar.gz
rneovim-953f26bace041f481e79b67b64401aa07259055c.tar.bz2
rneovim-953f26bace041f481e79b67b64401aa07259055c.zip
vim-patch:7.4.1975
Problem: On MS-Windows large files (> 2Gbyte) cause problems. Solution: Use "off_T" instead of "off_t". Use "stat_T" instead of "struct stat". Use 64 bit system functions if available. (Ken Takata) https://github.com/vim/vim/commit/8767f52fbfd4f053ce00a978227c95f1d7d323fe Only the off_T changes are relevant, since all the "struct stat" usage is abstracted by libuv.
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test_largefile.vim30
-rw-r--r--src/nvim/testdir/test_stat.vim64
3 files changed, 95 insertions, 0 deletions
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 70a9f2b8c4..77118c34bb 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -60,6 +60,7 @@ NEW_TESTS ?= \
test_quickfix.res \
test_signs.res \
test_smartindent.res \
+ test_stat.res \
test_substitute.res \
test_syntax.res \
test_tabpage.res \
diff --git a/src/nvim/testdir/test_largefile.vim b/src/nvim/testdir/test_largefile.vim
new file mode 100644
index 0000000000..ea2b8ff62d
--- /dev/null
+++ b/src/nvim/testdir/test_largefile.vim
@@ -0,0 +1,30 @@
+" Tests for large files
+" This is only executed manually: "make test_largefile".
+" This is not run as part of "make test".
+
+func Test_largefile()
+ let fname = 'Xlarge.txt'
+
+ call delete(fname)
+ exe "e" fname
+ " Make sure that a line break is 1 byte (LF).
+ set ff=unix
+ set undolevels=-1
+ " Input 99 'A's. The line becomes 100 bytes including a line break.
+ exe "normal 99iA\<Esc>"
+ yank
+ " Put 39,999,999 times. The file becomes 4,000,000,000 bytes.
+ normal 39999999p
+ " Moving around in the file randomly.
+ normal G
+ normal 10%
+ normal 90%
+ normal 50%
+ normal gg
+ w
+ " Check if the file size is larger than 2^31 - 1 bytes.
+ " Note that getfsize() returns -2 if a Number is 32 bits.
+ let fsize=getfsize(fname)
+ call assert_true(fsize > 2147483647 || fsize == -2)
+ "call delete(fname)
+endfunc
diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim
new file mode 100644
index 0000000000..89ca9ef379
--- /dev/null
+++ b/src/nvim/testdir/test_stat.vim
@@ -0,0 +1,64 @@
+" Tests for stat functions and checktime
+
+func Test_existent_file()
+ let fname='Xtest.tmp'
+
+ let ts=localtime()
+ sleep 1
+ let fl=['Hello World!']
+ call writefile(fl, fname)
+ let tf=getftime(fname)
+ sleep 1
+ let te=localtime()
+
+ call assert_true(ts <= tf && tf <= te)
+ call assert_equal(strlen(fl[0] . "\n"), getfsize(fname))
+ call assert_equal('file', getftype(fname))
+ call assert_equal('rw-', getfperm(fname)[0:2])
+endfunc
+
+func Test_existent_directory()
+ let dname='.'
+
+ call assert_equal(0, getfsize(dname))
+ call assert_equal('dir', getftype(dname))
+ call assert_equal('rwx', getfperm(dname)[0:2])
+endfunc
+
+func Test_checktime()
+ let fname='Xtest.tmp'
+
+ let fl=['Hello World!']
+ call writefile(fl, fname)
+ set autoread
+ exec 'e' fname
+ sleep 2
+ let fl=readfile(fname)
+ let fl[0] .= ' - checktime'
+ call writefile(fl, fname)
+ checktime
+ call assert_equal(fl[0], getline(1))
+endfunc
+
+func Test_nonexistent_file()
+ let fname='Xtest.tmp'
+
+ call delete(fname)
+ call assert_equal(-1, getftime(fname))
+ call assert_equal(-1, getfsize(fname))
+ call assert_equal('', getftype(fname))
+ call assert_equal('', getfperm(fname))
+endfunc
+
+func Test_win32_symlink_dir()
+ " On Windows, non-admin users cannot create symlinks.
+ " So we use an existing symlink for this test.
+ if has('win32')
+ " Check if 'C:\Users\All Users' is a symlink to a directory.
+ let res=system('dir C:\Users /a')
+ if match(res, '\C<SYMLINKD> *All Users') >= 0
+ " Get the filetype of the symlink.
+ call assert_equal('dir', getftype('C:\Users\All Users'))
+ endif
+ endif
+endfunc