]> granicus.if.org Git - vim/commitdiff
patch 8.2.1505: not all file read and writecode is tested v8.2.1505
authorBram Moolenaar <Bram@vim.org>
Fri, 21 Aug 2020 20:46:11 +0000 (22:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 21 Aug 2020 20:46:11 +0000 (22:46 +0200)
Problem:    Not all file read and writecode is tested.
Solution:   Add a few tests. (Dominique PellĂ©, closes #6764)

src/testdir/test_eval_stuff.vim
src/testdir/test_fnamemodify.vim
src/testdir/test_functions.vim
src/version.c

index bca89f7a77cd73a7510179fa79fb1a47cc005aaa..02e7e14fd7e0719cb3168f0dafc5dc4bee1ab2e5 100644 (file)
@@ -74,18 +74,31 @@ func Test_readfile_binary()
   new
   call setline(1, ['one', 'two', 'three'])
   setlocal ff=dos
-  silent write XReadfile
-  let lines = 'XReadfile'->readfile()
+  silent write XReadfile_bin
+  let lines = 'XReadfile_bin'->readfile()
   call assert_equal(['one', 'two', 'three'], lines)
-  let lines = readfile('XReadfile', '', 2)
+  let lines = readfile('XReadfile_bin', '', 2)
   call assert_equal(['one', 'two'], lines)
-  let lines = readfile('XReadfile', 'b')
+  let lines = readfile('XReadfile_bin', 'b')
   call assert_equal(["one\r", "two\r", "three\r", ""], lines)
-  let lines = readfile('XReadfile', 'b', 2)
+  let lines = readfile('XReadfile_bin', 'b', 2)
   call assert_equal(["one\r", "two\r"], lines)
 
   bwipe!
-  call delete('XReadfile')
+  call delete('XReadfile_bin')
+endfunc
+
+func Test_readfile_bom()
+  call writefile(["\ufeffFOO", "FOO\ufeffBAR"], 'XReadfile_bom')
+  call assert_equal(['FOO', 'FOOBAR'], readfile('XReadfile_bom'))
+  call delete('XReadfile_bom')
+endfunc
+
+func Test_readfile_max()
+  call writefile(range(1, 4), 'XReadfile_max')
+  call assert_equal(['1', '2'], readfile('XReadfile_max', '', 2))
+  call assert_equal(['3', '4'], readfile('XReadfile_max', '', -2))
+  call delete('XReadfile_max')
 endfunc
 
 func Test_let_errmsg()
index f8ce0b14ac9f059ee62d959068b1393b31b9f0d0..bcbdf77ae491a9d7cedd80ac0fbe47aefd083c32 100644 (file)
@@ -11,6 +11,7 @@ func Test_fnamemodify()
   call assert_equal('/', fnamemodify('.', ':p')[-1:])
   call assert_equal('r', fnamemodify('.', ':p:h')[-1:])
   call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
+  call assert_equal($HOME .. "/foo" , fnamemodify('~/foo', ':p'))
   call assert_equal('test.out', fnamemodify('test.out', ':.'))
   call assert_equal('a', fnamemodify('../testdir/a', ':.'))
   call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
@@ -93,4 +94,9 @@ func Test_fnamemodify_er()
   call assert_equal('', fnamemodify(test_null_string(), test_null_string()))
 endfunc
 
+func Test_fnamemodify_fail()
+  call assert_fails('call fnamemodify({}, ":p")', 'E731:')
+  call assert_fails('call fnamemodify("x", {})', 'E731:')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index c2d906623dc6c043aea2c543013c277a9b3da0fb..dc06bd72ecb878b656dac8ca7f46ea56c0404eb6 100644 (file)
@@ -2516,6 +2516,19 @@ endfunc
 func Test_glob()
   call assert_equal('', glob(test_null_string()))
   call assert_equal('', globpath(test_null_string(), test_null_string()))
+
+  call writefile([], 'Xglob1')
+  call writefile([], 'XGLOB2')
+  set wildignorecase
+  " Sort output of glob() otherwise we end up with different
+  " ordering depending on whether file system is case-sensitive.
+  call assert_equal(['XGLOB2', 'Xglob1'], sort(glob('Xglob[12]', 0, 1)))
+  set wildignorecase&
+
+  call delete('Xglob1')
+  call delete('XGLOB2')
+
+  call assert_fails("call glob('*', 0, {})", 'E728:')
 endfunc
 
 " Test for browse()
index 6773a8899e68f83e7bd971a1288c01ff9f7d12aa..843fd43b64703b6cc98d74d91aa54f3dfce615d2 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1505,
 /**/
     1504,
 /**/