Skip to content

Commit 46aa6f9

Browse files
yegappanbrammool
authored andcommitted
patch 8.2.2873: not enough tests for writing buffers
Problem: Not enough tests for writing buffers. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #8229)
1 parent 56c9fd0 commit 46aa6f9

5 files changed

Lines changed: 72 additions & 3 deletions

File tree

src/testdir/test_buffer.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,24 @@ func Test_balt()
381381
call assert_equal('OtherBuffer', bufname())
382382
endfunc
383383

384+
" Test for the 'maxmem' and 'maxmemtot' options
385+
func Test_buffer_maxmem()
386+
" use 1KB per buffer and 2KB for all the buffers
387+
set maxmem=1 maxmemtot=2
388+
new
389+
let v:errmsg = ''
390+
" try opening some files
391+
edit test_arglist.vim
392+
call assert_equal('test_arglist.vim', bufname())
393+
edit test_eval_stuff.vim
394+
call assert_equal('test_eval_stuff.vim', bufname())
395+
b test_arglist.vim
396+
call assert_equal('test_arglist.vim', bufname())
397+
b test_eval_stuff.vim
398+
call assert_equal('test_eval_stuff.vim', bufname())
399+
close
400+
call assert_equal('', v:errmsg)
401+
set maxmem& maxmemtot&
402+
endfunc
403+
384404
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_cmdline.vim

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,13 +1309,22 @@ func Test_cmdlineclear_tabenter()
13091309
call delete('XtestCmdlineClearTabenter')
13101310
endfunc
13111311

1312-
" Test for failure in expanding special keywords in cmdline
1312+
" Test for expanding special keywords in cmdline
13131313
func Test_cmdline_expand_special()
13141314
%bwipe!
13151315
call assert_fails('e #', 'E499:')
13161316
call assert_fails('e <afile>', 'E495:')
13171317
call assert_fails('e <abuf>', 'E496:')
13181318
call assert_fails('e <amatch>', 'E497:')
1319+
1320+
call writefile([], 'Xfile.cpp')
1321+
call writefile([], 'Xfile.java')
1322+
new Xfile.cpp
1323+
call feedkeys(":e %:r\<C-A>\<C-B>\"\<CR>", 'xt')
1324+
call assert_equal('"e Xfile.cpp Xfile.java', @:)
1325+
close
1326+
call delete('Xfile.cpp')
1327+
call delete('Xfile.java')
13191328
endfunc
13201329

13211330
func Test_cmdwin_jump_to_win()
@@ -1823,5 +1832,24 @@ func Test_cmd_map_cmdlineChanged()
18231832
augroup END
18241833
endfunc
18251834

1835+
" Test for the 'suffixes' option
1836+
func Test_suffixes_opt()
1837+
call writefile([], 'Xfile')
1838+
call writefile([], 'Xfile.c')
1839+
call writefile([], 'Xfile.o')
1840+
set suffixes=
1841+
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
1842+
call assert_equal('"e Xfile Xfile.c Xfile.o', @:)
1843+
set suffixes=.c
1844+
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
1845+
call assert_equal('"e Xfile Xfile.o Xfile.c', @:)
1846+
set suffixes=,,
1847+
call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt')
1848+
call assert_equal('"e Xfile.c Xfile.o Xfile', @:)
1849+
set suffixes&
1850+
call delete('Xfile')
1851+
call delete('Xfile.c')
1852+
call delete('Xfile.o')
1853+
endfunc
18261854

18271855
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_functions.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,7 @@ endfunc
26302630
func Test_glob()
26312631
call assert_equal('', glob(test_null_string()))
26322632
call assert_equal('', globpath(test_null_string(), test_null_string()))
2633+
call assert_fails("let x = globpath(&rtp, 'syntax/c.vim', [])", 'E745:')
26332634

26342635
call writefile([], 'Xglob1')
26352636
call writefile([], 'XGLOB2')

src/testdir/test_writefile.vim

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func Test_write_readonly_dir()
471471
" Root can do it too.
472472
CheckNotRoot
473473

474-
call mkdir('Xdir')
474+
call mkdir('Xdir/')
475475
call writefile(['one'], 'Xdir/Xfile1')
476476
call setfperm('Xdir', 'r-xr--r--')
477477
" try to create a new file in the directory
@@ -754,7 +754,7 @@ func Test_read_write_bin()
754754
call assert_equal(0z6E6F656F6C0A, readfile('XNoEolSetEol', 'B'))
755755

756756
call delete('XNoEolSetEol')
757-
set ff&
757+
set ff& fixeol&
758758
bwipe! XNoEolSetEol
759759
endfunc
760760

@@ -897,4 +897,22 @@ func Test_write_backup_symlink()
897897
call delete('Xfile.bak')
898898
endfunc
899899

900+
" Test for ':write ++bin' and ':write ++nobin'
901+
func Test_write_binary_file()
902+
" create a file without an eol/eof character
903+
call writefile(0z616161, 'Xfile1', 'b')
904+
new Xfile1
905+
write ++bin Xfile2
906+
write ++nobin Xfile3
907+
call assert_equal(0z616161, readblob('Xfile2'))
908+
if has('win32')
909+
call assert_equal(0z6161610D.0A, readblob('Xfile3'))
910+
else
911+
call assert_equal(0z6161610A, readblob('Xfile3'))
912+
endif
913+
call delete('Xfile1')
914+
call delete('Xfile2')
915+
call delete('Xfile3')
916+
endfunc
917+
900918
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2873,
753755
/**/
754756
2872,
755757
/**/

0 commit comments

Comments
 (0)