aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_writefile.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-19 21:40:22 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-19 22:05:26 +0800
commitb7c86e24f7cc16e642b82a3a157fec06ddc41e51 (patch)
tree0fb427f4eef7c583c29f9637e425a785f1ccc31c /src/nvim/testdir/test_writefile.vim
parentefebf30784951e88657e5c9362f374725a056a71 (diff)
downloadrneovim-b7c86e24f7cc16e642b82a3a157fec06ddc41e51.tar.gz
rneovim-b7c86e24f7cc16e642b82a3a157fec06ddc41e51.tar.bz2
rneovim-b7c86e24f7cc16e642b82a3a157fec06ddc41e51.zip
vim-patch:8.2.0982: insufficient testing for reading/writing files
Problem: Insufficient testing for reading/writing files. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#6257) Add "ui_delay" to test_override() and use it for the CTRL-O test. https://github.com/vim/vim/commit/b340baed9f7fc1c19a0742e2214d54982190c15e Omit test_override(). Reorder test_writefile.vim to match Vim.
Diffstat (limited to 'src/nvim/testdir/test_writefile.vim')
-rw-r--r--src/nvim/testdir/test_writefile.vim44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim
index bfbba1f793..a8735bcaf1 100644
--- a/src/nvim/testdir/test_writefile.vim
+++ b/src/nvim/testdir/test_writefile.vim
@@ -128,6 +128,25 @@ func Test_nowrite_quit_split()
bwipe Xfile
endfunc
+func Test_writefile_sync_arg()
+ " This doesn't check if fsync() works, only that the argument is accepted.
+ call writefile(['one'], 'Xtest', 's')
+ call writefile(['two'], 'Xtest', 'S')
+ call delete('Xtest')
+endfunc
+
+func Test_writefile_sync_dev_stdout()
+ if !has('unix')
+ return
+ endif
+ if filewritable('/dev/stdout')
+ " Just check that this doesn't cause an error.
+ call writefile(['one'], '/dev/stdout', 's')
+ else
+ throw 'Skipped: /dev/stdout is not writable'
+ endif
+endfunc
+
func Test_writefile_autowrite()
set autowrite
new
@@ -237,29 +256,18 @@ func Test_write_errors()
call delete('Xfile')
endfunc
-func Test_writefile_sync_dev_stdout()
- if !has('unix')
- return
- endif
- if filewritable('/dev/stdout')
- " Just check that this doesn't cause an error.
- call writefile(['one'], '/dev/stdout', 's')
- else
- throw 'Skipped: /dev/stdout is not writable'
- endif
-endfunc
-
-func Test_writefile_sync_arg()
- " This doesn't check if fsync() works, only that the argument is accepted.
- call writefile(['one'], 'Xtest', 's')
- call writefile(['two'], 'Xtest', 'S')
- call delete('Xtest')
+" Test for writing a file using invalid file encoding
+func Test_write_invalid_encoding()
+ new
+ call setline(1, 'abc')
+ call assert_fails('write ++enc=axbyc Xfile', 'E213:')
+ close!
endfunc
" Tests for reading and writing files with conversion for Win32.
func Test_write_file_encoding()
- CheckMSWindows
throw 'skipped: Nvim does not support :w ++enc=cp1251'
+ CheckMSWindows
let save_encoding = &encoding
let save_fileencodings = &fileencodings
set encoding& fileencodings&