diff 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
line wrap: on
line diff
--- a/src/testdir/test_history.vim
+++ b/src/testdir/test_history.vim
@@ -70,6 +70,14 @@ function History_Tests(hist)
     call assert_equal('', histget(a:hist, i))
     call assert_equal('', histget(a:hist, i - 7 - 1))
   endfor
+
+  " Test for freeing an entry at the beginning of the history list
+  for i in range(1, 4)
+      call histadd(a:hist, 'text_' . i)
+  endfor
+  call histdel(a:hist, 1)
+  call assert_equal('', histget(a:hist, 1))
+  call assert_equal('text_4', histget(a:hist, 4))
 endfunction
 
 function Test_History()
@@ -115,14 +123,14 @@ endfunc
 func Test_history_size()
   let save_histsz = &history
   call histdel(':')
-  set history=5
+  set history=10
   for i in range(1, 5)
     call histadd(':', 'cmd' .. i)
   endfor
   call assert_equal(5, histnr(':'))
   call assert_equal('cmd5', histget(':', -1))
 
-  set history=10
+  set history=15
   for i in range(6, 10)
     call histadd(':', 'cmd' .. i)
   endfor
@@ -137,6 +145,15 @@ func Test_history_size()
   call assert_equal('cmd7', histget(':', 7))
   call assert_equal('abc', histget(':', -1))
 
+  " This test works only when the language is English
+  if v:lang == "C" || v:lang =~ '^[Ee]n'
+    set history=0
+    redir => v
+    call feedkeys(":history\<CR>", 'xt')
+    redir END
+    call assert_equal(["'history' option is zero"], split(v, "\n"))
+  endif
+
   let &history=save_histsz
 endfunc
 
@@ -158,4 +175,12 @@ func Test_history_search()
   delfunc SavePat
 endfunc
 
+" Test for making sure the key value is not stored in history
+func Test_history_crypt_key()
+  CheckFeature cryptv
+  call feedkeys(":set bs=2 key=abc ts=8\<CR>", 'xt')
+  call assert_equal('set bs=2 key= ts=8', histget(':'))
+  set key& bs& ts&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab