Mercurial > vim
comparison src/testdir/test_search_stat.vim @ 17968:22ddc0ee65e7 v8.1.1980
patch 8.1.1980: fix for search stat not tested
Commit: https://github.com/vim/vim/commit/0f63ed33fdd12d8220f7bc7ff91095e7ceed9985
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 4 16:32:36 2019 +0200
patch 8.1.1980: fix for search stat not tested
Problem: Fix for search stat not tested.
Solution: Add a screenshot test. (Christian Brabandt)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 04 Sep 2019 16:45:04 +0200 |
parents | c77a41ea0365 |
children | a9c54c20295c |
comparison
equal
deleted
inserted
replaced
17967:58e90151e63f | 17968:22ddc0ee65e7 |
---|---|
1 " Tests for search_stats, when "S" is not in 'shortmess' | 1 " Tests for search_stats, when "S" is not in 'shortmess' |
2 " | 2 |
3 " This test is fragile, it might not work interactively, but it works when run | 3 source check.vim |
4 " as test! | 4 source screendump.vim |
5 | 5 |
6 source shared.vim | 6 func Test_search_stat() |
7 | |
8 func! Test_search_stat() | |
9 new | 7 new |
10 set shortmess-=S | 8 set shortmess-=S |
11 " Append 50 lines with text to search for, "foobar" appears 20 times | 9 " Append 50 lines with text to search for, "foobar" appears 20 times |
12 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) | 10 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 10)) |
13 | 11 |
175 let g:a = execute(':unsilent :norm n') | 173 let g:a = execute(':unsilent :norm n') |
176 let g:b = split(g:a, "\n")[-1] | 174 let g:b = split(g:a, "\n")[-1] |
177 let stat = '\[1/2\]' | 175 let stat = '\[1/2\]' |
178 call assert_notmatch(pat .. stat, g:b) | 176 call assert_notmatch(pat .. stat, g:b) |
179 call assert_match(stat, g:b) | 177 call assert_match(stat, g:b) |
178 " Test that the message is not truncated | |
179 " it would insert '...' into the output. | |
180 call assert_match('^\s\+' .. stat, g:b) | |
180 unmap n | 181 unmap n |
181 | 182 |
182 " Clean up | 183 " Clean up |
183 set shortmess+=S | 184 set shortmess+=S |
184 | |
185 " close the window | 185 " close the window |
186 bwipe! | 186 bwipe! |
187 endfunc | 187 endfunc |
188 | |
189 func! Test_search_stat_screendump() | |
190 CheckScreendump | |
191 | |
192 let lines =<< trim END | |
193 set shortmess-=S | |
194 " Append 50 lines with text to search for, "foobar" appears 20 times | |
195 call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20)) | |
196 call setline(2, 'find this') | |
197 call setline(70, 'find this') | |
198 nnoremap n n | |
199 let @/ = 'find this' | |
200 call cursor(1,1) | |
201 norm n | |
202 END | |
203 call writefile(lines, 'Xsearchstat') | |
204 let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10}) | |
205 call term_wait(buf) | |
206 call VerifyScreenDump(buf, 'Test_searchstat_1', {}) | |
207 | |
208 call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>") | |
209 call term_sendkeys(buf, "gg0n") | |
210 call term_wait(buf) | |
211 call VerifyScreenDump(buf, 'Test_searchstat_2', {}) | |
212 | |
213 call StopVimInTerminal(buf) | |
214 call delete('Xsearchstat') | |
215 endfunc |