diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-29 19:20:22 +0200 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-29 19:55:42 +0200 |
| commit | 24b7462b3cbf9a70f07f0a8e8da562a365cdc37a (patch) | |
| tree | 59bc0d9761679ba4f0528bf591e0adab2b934622 /src/nvim/testdir | |
| parent | a0d723db55cf2b81e3bd9271cda9b1b58a5c9f3c (diff) | |
| download | rneovim-24b7462b3cbf9a70f07f0a8e8da562a365cdc37a.tar.gz rneovim-24b7462b3cbf9a70f07f0a8e8da562a365cdc37a.tar.bz2 rneovim-24b7462b3cbf9a70f07f0a8e8da562a365cdc37a.zip | |
vim-patch:8.1.0313: information about a swap file is unavailable
Problem: Information about a swap file is unavailable.
Solution: Add swapinfo(). (Enzo Ferber)
https://github.com/vim/vim/commit/00f123a56585363cd13f062fd3bb123efcfaa664
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_swap.vim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_swap.vim b/src/nvim/testdir/test_swap.vim index bc7b7c00d3..28f995f6fb 100644 --- a/src/nvim/testdir/test_swap.vim +++ b/src/nvim/testdir/test_swap.vim @@ -61,3 +61,37 @@ func Test_missing_dir() set directory& call delete('Xswapdir', 'rf') endfunc + +func Test_swapinfo() + new Xswapinfo + call setline(1, ['one', 'two', 'three']) + w + let fname = trim(execute('swapname')) + call assert_match('Xswapinfo', fname) + let info = swapinfo(fname) + call assert_match('8\.', info.version) + call assert_match('\w', info.user) + call assert_equal(hostname(), info.host) + call assert_match('Xswapinfo', info.fname) + call assert_equal(getpid(), info.pid) + call assert_match('^\d*$', info.mtime) + if has_key(info, 'inode') + call assert_match('\d', info.inode) + endif + bwipe! + call delete(fname) + call delete('Xswapinfo') + + let info = swapinfo('doesnotexist') + call assert_equal('Cannot open file', info.error) + + call writefile(['burp'], 'Xnotaswapfile') + let info = swapinfo('Xnotaswapfile') + call assert_equal('Cannot read file', info.error) + call delete('Xnotaswapfile') + + call writefile([repeat('x', 10000)], 'Xnotaswapfile') + let info = swapinfo('Xnotaswapfile') + call assert_equal('magic number mismatch', info.error) + call delete('Xnotaswapfile') +endfunc |