diff options
Diffstat (limited to 'src/nvim/testdir/test_hardcopy.vim')
-rw-r--r-- | src/nvim/testdir/test_hardcopy.vim | 80 |
1 files changed, 57 insertions, 23 deletions
diff --git a/src/nvim/testdir/test_hardcopy.vim b/src/nvim/testdir/test_hardcopy.vim index 6125f9b993..e390bd5cc8 100644 --- a/src/nvim/testdir/test_hardcopy.vim +++ b/src/nvim/testdir/test_hardcopy.vim @@ -1,5 +1,7 @@ " Test :hardcopy +source check.vim + func Test_printoptions() edit test_hardcopy.vim syn on @@ -8,8 +10,10 @@ func Test_printoptions() \ 'left:2in,top:30pt,right:16mm,bottom:3pc', \ 'header:3,syntax:y,number:y,wrap:n', \ 'header:3,syntax:n,number:y,wrap:y', + \ 'header:0,syntax:a,number:y,wrap:y', \ 'duplex:short,collate:n,jobsplit:y,portrait:n', \ 'duplex:long,collate:y,jobsplit:n,portrait:y', + \ 'duplex:off,collate:y,jobsplit:y,portrait:y', \ 'paper:10x14', \ 'paper:A3', \ 'paper:A4', @@ -28,7 +32,7 @@ func Test_printoptions() \ ''] exe 'set printoptions=' .. opt if has('postscript') - hardcopy > Xhardcopy_printoptions + 1,50hardcopy > Xhardcopy_printoptions let lines = readfile('Xhardcopy_printoptions') call assert_true(len(lines) > 20, opt) call assert_true(lines[0] =~ 'PS-Adobe', opt) @@ -44,8 +48,8 @@ func Test_printoptions() endfunc func Test_printmbfont() - " Print a small help page which contains tabs to cover code that expands tabs to spaces. - help help + " Print a help page which contains tabs, underlines (etc) to recover more code. + help syntax.txt syn on for opt in [':WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-Bold-Italic,c:yes,a:no', @@ -63,10 +67,39 @@ func Test_printmbfont() bwipe endfunc +func Test_printmbcharset() + CheckFeature postscript + + " digraph.txt has plenty of non-latin1 characters. + help digraph.txt + set printmbcharset=ISO10646 printencoding=utf-8 + for courier in ['yes', 'no'] + for ascii in ['yes', 'no'] + exe 'set printmbfont=r:WadaMin-Regular,b:WadaMin-Bold,i:WadaMin-Italic,o:WadaMin-BoldItalic' + \ .. ',c:' .. courier .. ',a:' .. ascii + hardcopy > Xhardcopy_printmbcharset + let lines = readfile('Xhardcopy_printmbcharset') + call assert_true(len(lines) > 20) + call assert_true(lines[0] =~ 'PS-Adobe') + endfor + endfor + + set printmbcharset=does-not-exist printencoding=utf-8 printmbfont=r:WadaMin-Regular + call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E456:') + + set printmbcharset=GB_2312-80 printencoding=utf-8 printmbfont=r:WadaMin-Regular + call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E673:') + + set printmbcharset=ISO10646 printencoding=utf-8 printmbfont= + call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E675:') + + call delete('Xhardcopy_printmbcharset') + set printmbcharset& printencoding& printmbfont& + bwipe +endfunc + func Test_printexpr() - if !has('unix') - return - endif + CheckFeature postscript " Not a very useful printexpr value, but enough to test " hardcopy with 'printexpr'. @@ -84,7 +117,7 @@ func Test_printexpr() \ readfile('Xhardcopy_printexpr')) call delete('Xhardcopy_printexpr') - " Function return 1 to test print failure. + " Function returns 1 to test print failure. function PrintFails(fname) call delete(a:fname) return 1 @@ -97,12 +130,11 @@ func Test_printexpr() endfunc func Test_errors() - " FIXME: Windows fails differently than Unix. - if has('unix') - edit test_hardcopy.vim - call assert_fails('hardcopy >', 'E324:') - bwipe - endif + CheckFeature postscript + + edit test_hardcopy.vim + call assert_fails('hardcopy >', 'E324:') + bwipe endfunc func Test_dark_background() @@ -126,12 +158,11 @@ func Test_dark_background() endfun func Test_empty_buffer() - " FIXME: Unclear why this fails on Windows. - if has('unix') - new - call assert_equal("\nNo text to be printed", execute('hardcopy')) - bwipe - endif + CheckFeature postscript + + new + call assert_equal("\nNo text to be printed", execute('hardcopy')) + bwipe endfunc func Test_printheader_parsing() @@ -145,9 +176,8 @@ func Test_printheader_parsing() endfunc func Test_fname_with_spaces() - if !has('postscript') - return - endif + CheckFeature postscript + split t\ e\ s\ t.txt call setline(1, ['just', 'some', 'text']) hardcopy > %.ps @@ -157,9 +187,11 @@ func Test_fname_with_spaces() endfunc func Test_illegal_byte() - if !has('postscript') || &enc != 'utf-8' + CheckFeature postscript + if &enc != 'utf-8' return endif + new " conversion of 0xff will fail, this used to cause a crash call setline(1, "\xff") @@ -168,3 +200,5 @@ func Test_illegal_byte() bwipe! call delete('Xpstest') endfunc + +" vim: shiftwidth=2 sts=2 expandtab |