aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-09-29 19:33:01 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-09-29 19:45:06 -0400
commita307489a79450a0f54282f11203ae68577505ab4 (patch)
tree138326514595052d19116f3765e7246893dd316d
parent37c6cbc7588717c2e1396779d4d69fb3e3263c2d (diff)
downloadrneovim-a307489a79450a0f54282f11203ae68577505ab4.tar.gz
rneovim-a307489a79450a0f54282f11203ae68577505ab4.tar.bz2
rneovim-a307489a79450a0f54282f11203ae68577505ab4.zip
vim-patch:8.1.1980: fix for search stat not tested
Problem: Fix for search stat not tested. Solution: Add a screenshot test. (Christian Brabandt) https://github.com/vim/vim/commit/0f63ed33fdd12d8220f7bc7ff91095e7ceed9985
-rw-r--r--src/nvim/testdir/test_search_stat.vim38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/nvim/testdir/test_search_stat.vim b/src/nvim/testdir/test_search_stat.vim
index 3dd0bec8c9..1188c220e1 100644
--- a/src/nvim/testdir/test_search_stat.vim
+++ b/src/nvim/testdir/test_search_stat.vim
@@ -1,13 +1,9 @@
" Tests for search_stats, when "S" is not in 'shortmess'
-"
-" This test is fragile, it might not work interactively, but it works when run
-" as test!
-source shared.vim
source screendump.vim
source check.vim
-func! Test_search_stat()
+func Test_search_stat()
new
set shortmess-=S
" Append 50 lines with text to search for, "foobar" appears 20 times
@@ -179,15 +175,45 @@ func! Test_search_stat()
let stat = '\[1/2\]'
call assert_notmatch(pat .. stat, g:b)
call assert_match(stat, g:b)
+ " Test that the message is not truncated
+ " it would insert '...' into the output.
+ call assert_match('^\s\+' .. stat, g:b)
unmap n
" Clean up
set shortmess+=S
-
" close the window
bwipe!
endfunc
+func! Test_search_stat_screendump()
+ CheckScreendump
+
+ let lines =<< trim END
+ set shortmess-=S
+ " Append 50 lines with text to search for, "foobar" appears 20 times
+ call append(0, repeat(['foobar', 'foo', 'fooooobar', 'foba', 'foobar'], 20))
+ call setline(2, 'find this')
+ call setline(70, 'find this')
+ nnoremap n n
+ let @/ = 'find this'
+ call cursor(1,1)
+ norm n
+ END
+ call writefile(lines, 'Xsearchstat')
+ let buf = RunVimInTerminal('-S Xsearchstat', #{rows: 10})
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_searchstat_1', {})
+
+ call term_sendkeys(buf, ":nnoremap <silent> n n\<cr>")
+ call term_sendkeys(buf, "gg0n")
+ call term_wait(buf)
+ call VerifyScreenDump(buf, 'Test_searchstat_2', {})
+
+ call StopVimInTerminal(buf)
+ call delete('Xsearchstat')
+endfunc
+
func Test_searchcount_in_statusline()
CheckScreendump