diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-08-21 20:28:54 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-08-21 20:28:54 +0200 |
commit | 00f123a56585363cd13f062fd3bb123efcfaa664 (patch) | |
tree | 7c8fb2556c2b395cb4d6035a1b0299f05073e409 /src/testdir/test_swap.vim | |
parent | 8e82c057ffb86cec3210ad8a22ad3f21d52e0953 (diff) | |
download | vim-git-00f123a56585363cd13f062fd3bb123efcfaa664.tar.gz |
patch 8.1.0313: information about a swap file is unavailablev8.1.0313
Problem: Information about a swap file is unavailable.
Solution: Add swapinfo(). (Enzo Ferber)
Diffstat (limited to 'src/testdir/test_swap.vim')
-rw-r--r-- | src/testdir/test_swap.vim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/testdir/test_swap.vim b/src/testdir/test_swap.vim index da5da2dbb..b0e2ec9aa 100644 --- a/src/testdir/test_swap.vim +++ b/src/testdir/test_swap.vim @@ -97,3 +97,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 |