patch 8.0.1816: no test for setcmdpos() v8.0.1816
authorBram Moolenaar <Bram@vim.org>
Sat, 12 May 2018 11:18:46 +0000 (13:18 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 May 2018 11:18:46 +0000 (13:18 +0200)
Problem:    No test for setcmdpos().
Solution:   Add a test. (Dominique Pelle, closes #2901)

src/testdir/test_cmdline.vim
src/version.c

index a79f2761cbe634c815985175d9a9fa7786ed7a8e..473c35dcf9cac57d3d8a0a371bda5a591b3ca74a 100644 (file)
@@ -470,4 +470,25 @@ func Test_verbosefile()
   call delete('Xlog')
 endfunc
 
+func Test_setcmdpos()
+  func InsertTextAtPos(text, pos)
+    call assert_equal(0, setcmdpos(a:pos))
+    return a:text
+  endfunc
+
+  " setcmdpos() with position in the middle of the command line.
+  call feedkeys(":\"12\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
+  call assert_equal('"1ab2', @:)
+
+  call feedkeys(":\"12\<C-R>\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
+  call assert_equal('"1b2a', @:)
+
+  " setcmdpos() with position beyond the end of the command line.
+  call feedkeys(":\"12\<C-B>\<C-R>=InsertTextAtPos('a', 10)\<CR>b\<CR>", 'xt')
+  call assert_equal('"12ab', @:)
+
+  " setcmdpos() returns 1 when not editing the command line.
+  call assert_equal(1, setcmdpos(3))
+endfunc
+
 set cpo&
index 6346e62171daf12a8eac32d1b562cc742e8104a4..f94090fb4713620d01174a877f77e4e14f022075 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1816,
 /**/
     1815,
 /**/