patch 8.2.0316: ex_getln.c code has insufficient test coverage

Problem:    ex_getln.c code has insufficient test coverage.
Solution:   Add more tests. Fix a problem. (Yegappan Lakshmanan, closes #5693)
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 545f09b..fa3446a 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -51,6 +51,12 @@
   call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
   call assert_equal('testfile1', getline(1))
 
+  " Completion using a relative path
+  cd Xdir1/Xdir2
+  call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_equal('"e Xtestfile3 Xtestfile4', @:)
+  cd -
+
   " cleanup
   %bwipe
   call delete('Xdir1/Xdir2/Xtestfile4')
@@ -456,6 +462,10 @@
     " ignore error E32
   endtry
   call assert_equal("Xtestfile", bufname("%"))
+
+  " Use an invalid expression for <C-\>e
+  call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
+
   bwipe!
 endfunc
 
@@ -690,6 +700,8 @@
   cnoremap <expr> <F6> Check_cmdline('=')
   call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
   cunmap <F6>
+
+  call assert_equal('', getcmdline())
 endfunc
 
 func Test_getcmdwintype()
@@ -930,6 +942,22 @@
   delfunc CmdWinType
 endfunc
 
+" Test for CmdwinEnter autocmd
+func Test_cmdwin_autocmd()
+  augroup CmdWin
+    au!
+    autocmd CmdwinEnter * startinsert
+  augroup END
+
+  call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:')
+  call assert_equal('xyz', @:)
+
+  augroup CmdWin
+    au!
+  augroup END
+  augroup! CmdWin
+endfunc
+
 func Test_cmdlineclear_tabenter()
   CheckScreendump
 
@@ -967,6 +995,10 @@
   call assert_equal(1, winnr('$'))
   call feedkeys("q/:exit\<CR>", "xt")
   call assert_equal(1, winnr('$'))
+
+  " opening command window twice should fail
+  call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
+  call assert_equal(1, winnr('$'))
 endfunc
 
 " Test for backtick expression in the command line
@@ -1006,4 +1038,19 @@
   call delete('Xresult')
 endfunc
 
+" Test for using ~ for home directory in cmdline completion matches
+func Test_cmdline_expand_home()
+  call mkdir('Xdir')
+  call writefile([], 'Xdir/Xfile1')
+  call writefile([], 'Xdir/Xfile2')
+  cd Xdir
+  let save_HOME = $HOME
+  let $HOME = getcwd()
+  call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
+  let $HOME = save_HOME
+  cd ..
+  call delete('Xdir', 'rf')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab