comparison src/testdir/test_history.vim @ 19536:bab20768e1fd v8.2.0325

patch 8.2.0325: ex_getln.c code not covered by tests Commit: https://github.com/vim/vim/commit/578fe947e3ad0cc7313c798cf76cc43dbf9b4ea6 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 27 21:32:51 2020 +0100 patch 8.2.0325: ex_getln.c code not covered by tests Problem: Ex_getln.c code not covered by tests. Solution: Add a few more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5702)
author Bram Moolenaar <Bram@vim.org>
date Thu, 27 Feb 2020 21:45:04 +0100
parents 738a4fe2c8c5
children 43c04edcafec
comparison
equal deleted inserted replaced
19535:b8ce0a9d1657 19536:bab20768e1fd
68 call histdel(a:hist) 68 call histdel(a:hist)
69 for i in range(1, 7) 69 for i in range(1, 7)
70 call assert_equal('', histget(a:hist, i)) 70 call assert_equal('', histget(a:hist, i))
71 call assert_equal('', histget(a:hist, i - 7 - 1)) 71 call assert_equal('', histget(a:hist, i - 7 - 1))
72 endfor 72 endfor
73
74 " Test for freeing an entry at the beginning of the history list
75 for i in range(1, 4)
76 call histadd(a:hist, 'text_' . i)
77 endfor
78 call histdel(a:hist, 1)
79 call assert_equal('', histget(a:hist, 1))
80 call assert_equal('text_4', histget(a:hist, 4))
73 endfunction 81 endfunction
74 82
75 function Test_History() 83 function Test_History()
76 for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>'] 84 for h in ['cmd', ':', '', 'search', '/', '?', 'expr', '=', 'input', '@', 'debug', '>']
77 call History_Tests(h) 85 call History_Tests(h)
113 121
114 " Test for increasing the 'history' option value 122 " Test for increasing the 'history' option value
115 func Test_history_size() 123 func Test_history_size()
116 let save_histsz = &history 124 let save_histsz = &history
117 call histdel(':') 125 call histdel(':')
118 set history=5 126 set history=10
119 for i in range(1, 5) 127 for i in range(1, 5)
120 call histadd(':', 'cmd' .. i) 128 call histadd(':', 'cmd' .. i)
121 endfor 129 endfor
122 call assert_equal(5, histnr(':')) 130 call assert_equal(5, histnr(':'))
123 call assert_equal('cmd5', histget(':', -1)) 131 call assert_equal('cmd5', histget(':', -1))
124 132
125 set history=10 133 set history=15
126 for i in range(6, 10) 134 for i in range(6, 10)
127 call histadd(':', 'cmd' .. i) 135 call histadd(':', 'cmd' .. i)
128 endfor 136 endfor
129 call assert_equal(10, histnr(':')) 137 call assert_equal(10, histnr(':'))
130 call assert_equal('cmd1', histget(':', 1)) 138 call assert_equal('cmd1', histget(':', 1))
134 call histadd(':', 'abc') 142 call histadd(':', 'abc')
135 call assert_equal('', histget(':', 6)) 143 call assert_equal('', histget(':', 6))
136 call assert_equal('', histget(':', 12)) 144 call assert_equal('', histget(':', 12))
137 call assert_equal('cmd7', histget(':', 7)) 145 call assert_equal('cmd7', histget(':', 7))
138 call assert_equal('abc', histget(':', -1)) 146 call assert_equal('abc', histget(':', -1))
147
148 " This test works only when the language is English
149 if v:lang == "C" || v:lang =~ '^[Ee]n'
150 set history=0
151 redir => v
152 call feedkeys(":history\<CR>", 'xt')
153 redir END
154 call assert_equal(["'history' option is zero"], split(v, "\n"))
155 endif
139 156
140 let &history=save_histsz 157 let &history=save_histsz
141 endfunc 158 endfunc
142 159
143 " Test for recalling old search patterns in / 160 " Test for recalling old search patterns in /
156 call assert_equal(['pat2', 'pat1', ''], g:pat) 173 call assert_equal(['pat2', 'pat1', ''], g:pat)
157 cunmap <F2> 174 cunmap <F2>
158 delfunc SavePat 175 delfunc SavePat
159 endfunc 176 endfunc
160 177
178 " Test for making sure the key value is not stored in history
179 func Test_history_crypt_key()
180 CheckFeature cryptv
181 call feedkeys(":set bs=2 key=abc ts=8\<CR>", 'xt')
182 call assert_equal('set bs=2 key= ts=8', histget(':'))
183 set key& bs& ts&
184 endfunc
185
161 " vim: shiftwidth=2 sts=2 expandtab 186 " vim: shiftwidth=2 sts=2 expandtab