comparison src/testdir/test_hardcopy.vim @ 19663:f43c0e669bd6 v8.2.0388

patch 8.2.0388: printmbcharset option not tested Commit: https://github.com/vim/vim/commit/833805a4867cf5f93b3ef91227d1f1a98f553dff Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 15 18:27:43 2020 +0100 patch 8.2.0388: printmbcharset option not tested Problem: Printmbcharset option not tested. Solution: Add a test. Enable PostScript for AppVeyor build. (Dominique Pelle, closes #5783)
author Bram Moolenaar <Bram@vim.org>
date Sun, 15 Mar 2020 18:30:05 +0100
parents 1eb83d461033
children 8fa9d31cd248
comparison
equal deleted inserted replaced
19662:3687efb39b68 19663:f43c0e669bd6
1 " Test :hardcopy 1 " Test :hardcopy
2
3 source check.vim
2 4
3 func Test_printoptions() 5 func Test_printoptions()
4 edit test_hardcopy.vim 6 edit test_hardcopy.vim
5 syn on 7 syn on
6 8
26 \ 'paper:tabloid', 28 \ 'paper:tabloid',
27 \ 'formfeed:y', 29 \ 'formfeed:y',
28 \ ''] 30 \ '']
29 exe 'set printoptions=' .. opt 31 exe 'set printoptions=' .. opt
30 if has('postscript') 32 if has('postscript')
31 hardcopy > Xhardcopy_printoptions 33 1,50hardcopy > Xhardcopy_printoptions
32 let lines = readfile('Xhardcopy_printoptions') 34 let lines = readfile('Xhardcopy_printoptions')
33 call assert_true(len(lines) > 20, opt) 35 call assert_true(len(lines) > 20, opt)
34 call assert_true(lines[0] =~ 'PS-Adobe', opt) 36 call assert_true(lines[0] =~ 'PS-Adobe', opt)
35 call delete('Xhardcopy_printoptions') 37 call delete('Xhardcopy_printoptions')
36 endif 38 endif
61 endfor 63 endfor
62 set printmbfont& 64 set printmbfont&
63 bwipe 65 bwipe
64 endfunc 66 endfunc
65 67
68 func Test_printmbcharset()
69 CheckFeature postscript
70
71 " digraph.txt has plenty of non-latin1 characters.
72 help digraph.txt
73 set printmbcharset=ISO10646 printencoding=utf-8 printmbfont=r:WadaMin-Regular
74
75 hardcopy > Xhardcopy_printmbcharset
76 let lines = readfile('Xhardcopy_printmbcharset')
77 call assert_true(len(lines) > 20)
78 call assert_true(lines[0] =~ 'PS-Adobe')
79
80 set printmbcharset=does-not-exist printencoding=utf-8 printmbfont=r:WadaMin-Regular
81 call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E456:')
82
83 set printmbcharset=GB_2312-80 printencoding=utf-8 printmbfont=r:WadaMin-Regular
84 call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E673:')
85
86 set printmbcharset=ISO10646 printencoding=utf-8 printmbfont=
87 call assert_fails('hardcopy > Xhardcopy_printmbcharset', 'E675:')
88
89 call delete('Xhardcopy_printmbcharset')
90 set printmbcharset& printencoding& printmbfont&
91 bwipe
92 endfunc
93
66 func Test_printexpr() 94 func Test_printexpr()
67 if !has('unix') 95 CheckFeature postscript
68 return
69 endif
70 96
71 " Not a very useful printexpr value, but enough to test 97 " Not a very useful printexpr value, but enough to test
72 " hardcopy with 'printexpr'. 98 " hardcopy with 'printexpr'.
73 function PrintFile(fname) 99 function PrintFile(fname)
74 call writefile(['Test printexpr: ' .. v:cmdarg], 100 call writefile(['Test printexpr: ' .. v:cmdarg],
82 hardcopy dummy args 108 hardcopy dummy args
83 call assert_equal(['Test printexpr: dummy args'], 109 call assert_equal(['Test printexpr: dummy args'],
84 \ readfile('Xhardcopy_printexpr')) 110 \ readfile('Xhardcopy_printexpr'))
85 call delete('Xhardcopy_printexpr') 111 call delete('Xhardcopy_printexpr')
86 112
87 " Function return 1 to test print failure. 113 " Function returns 1 to test print failure.
88 function PrintFails(fname) 114 function PrintFails(fname)
89 call delete(a:fname) 115 call delete(a:fname)
90 return 1 116 return 1
91 endfunc 117 endfunc
92 set printexpr=PrintFails(v:fname_in) 118 set printexpr=PrintFails(v:fname_in)
95 set printexpr& 121 set printexpr&
96 bwipe 122 bwipe
97 endfunc 123 endfunc
98 124
99 func Test_errors() 125 func Test_errors()
100 " FIXME: Windows fails differently than Unix. 126 CheckFeature postscript
101 if has('unix') 127
102 edit test_hardcopy.vim 128 edit test_hardcopy.vim
103 call assert_fails('hardcopy >', 'E324:') 129 call assert_fails('hardcopy >', 'E324:')
104 bwipe 130 bwipe
105 endif
106 endfunc 131 endfunc
107 132
108 func Test_dark_background() 133 func Test_dark_background()
109 edit test_hardcopy.vim 134 edit test_hardcopy.vim
110 syn on 135 syn on
124 set background& 149 set background&
125 bwipe 150 bwipe
126 endfun 151 endfun
127 152
128 func Test_empty_buffer() 153 func Test_empty_buffer()
129 " FIXME: Unclear why this fails on Windows. 154 CheckFeature postscript
130 if has('unix') 155
131 new 156 new
132 call assert_equal("\nNo text to be printed", execute('hardcopy')) 157 call assert_equal("\nNo text to be printed", execute('hardcopy'))
133 bwipe 158 bwipe
134 endif
135 endfunc 159 endfunc
136 160
137 func Test_printheader_parsing() 161 func Test_printheader_parsing()
138 " Only test that this doesn't throw an error. 162 " Only test that this doesn't throw an error.
139 set printheader=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P 163 set printheader=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
143 set printheader= 167 set printheader=
144 set printheader& 168 set printheader&
145 endfunc 169 endfunc
146 170
147 func Test_fname_with_spaces() 171 func Test_fname_with_spaces()
148 if !has('postscript') 172 CheckFeature postscript
149 return 173
150 endif
151 split t\ e\ s\ t.txt 174 split t\ e\ s\ t.txt
152 call setline(1, ['just', 'some', 'text']) 175 call setline(1, ['just', 'some', 'text'])
153 hardcopy > %.ps 176 hardcopy > %.ps
154 call assert_true(filereadable('t e s t.txt.ps')) 177 call assert_true(filereadable('t e s t.txt.ps'))
155 call delete('t e s t.txt.ps') 178 call delete('t e s t.txt.ps')
156 bwipe! 179 bwipe!
157 endfunc 180 endfunc
158 181
159 func Test_illegal_byte() 182 func Test_illegal_byte()
160 if !has('postscript') || &enc != 'utf-8' 183 CheckFeature postscript
184 if &enc != 'utf-8'
161 return 185 return
162 endif 186 endif
187
163 new 188 new
164 " conversion of 0xff will fail, this used to cause a crash 189 " conversion of 0xff will fail, this used to cause a crash
165 call setline(1, "\xff") 190 call setline(1, "\xff")
166 hardcopy >Xpstest 191 hardcopy >Xpstest
167 192
168 bwipe! 193 bwipe!
169 call delete('Xpstest') 194 call delete('Xpstest')
170 endfunc 195 endfunc
196
197 " vim: shiftwidth=2 sts=2 expandtab