diff src/testdir/test_history.vim @ 19581:848dc460adf0 v8.2.0347

patch 8.2.0347: various code not covered by tests Commit: https://github.com/vim/vim/commit/91ffc8a5f5c7b1c6979b3352a12ed779d11173a9 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 2 20:54:22 2020 +0100 patch 8.2.0347: various code not covered by tests Problem: Various code not covered by tests. Solution: Add more test coverage. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5720)
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Mar 2020 21:00:04 +0100
parents 43c04edcafec
children 595ea7f099cd
line wrap: on
line diff
--- a/src/testdir/test_history.vim
+++ b/src/testdir/test_history.vim
@@ -176,12 +176,52 @@ func Test_history_search()
   cunmap <F2>
   delfunc SavePat
 
+  " Search for a pattern that is not present in the history
+  call assert_beeps('call feedkeys("/a1b2\<Up>\<CR>", "xt")')
+
   " Recall patterns with 'history' set to 0
   set history=0
   let @/ = 'abc'
   let cmd = 'call feedkeys("/\<Up>\<Down>\<S-Up>\<S-Down>\<CR>", "xt")'
   call assert_fails(cmd, 'E486:')
   set history&
+
+  " Recall patterns till the end of history
+  set history=4
+  call histadd('/', 'pat')
+  call histdel('/')
+  call histadd('/', 'pat1')
+  call histadd('/', 'pat2')
+  call assert_beeps('call feedkeys("/\<Up>\<Up>\<Up>\<C-U>\<cr>", "xt")')
+  call assert_beeps('call feedkeys("/\<Down><cr>", "xt")')
+
+  " Test for wrapping around the history list
+  for i in range(3, 7)
+    call histadd('/', 'pat' .. i)
+  endfor
+  let upcmd = "\<up>\<up>\<up>\<up>\<up>"
+  let downcmd = "\<down>\<down>\<down>\<down>\<down>"
+  try
+    call feedkeys("/" .. upcmd .. "\<cr>", 'xt')
+  catch /E486:/
+  endtry
+  call assert_equal('pat4', @/)
+  try
+    call feedkeys("/" .. upcmd .. downcmd .. "\<cr>", 'xt')
+  catch /E486:/
+  endtry
+  call assert_equal('pat4', @/)
+
+  " Test for changing the search command separator in the history
+  call assert_fails('call feedkeys("/def/\<cr>", "xt")', 'E486:')
+  call assert_fails('call feedkeys("?\<up>\<cr>", "xt")', 'E486:')
+  call assert_equal('def?', histget('/', -1))
+
+  call assert_fails('call feedkeys("/ghi?\<cr>", "xt")', 'E486:')
+  call assert_fails('call feedkeys("?\<up>\<cr>", "xt")', 'E486:')
+  call assert_equal('ghi\?', histget('/', -1))
+
+  set history&
 endfunc
 
 " Test for making sure the key value is not stored in history