diff src/testdir/test_goto.vim @ 20199:a4bd28e2cf1d v8.2.0655

patch 8.2.0655: search code not sufficiently tested Commit: https://github.com/vim/vim/commit/224a5f17c6ec9e98322a4c6792ce4f9bb31a4cce Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 28 20:29:07 2020 +0200 patch 8.2.0655: search code not sufficiently tested Problem: Search code not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5999)
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 Apr 2020 20:30:04 +0200
parents 6990c1160ea5
children 1503ecd54f8a
line wrap: on
line diff
--- a/src/testdir/test_goto.vim
+++ b/src/testdir/test_goto.vim
@@ -333,21 +333,24 @@ endfunc
 
 func Test_motion_if_elif_else_endif()
   new
-  a
-/* Test pressing % on #if, #else #elsif and #endif,
- * with nested #if
- */
-#if FOO
-/* ... */
-#  if BAR
-/* ... */
-#  endif
-#elif BAR
-/* ... */
-#else
-/* ... */
-#endif
-.
+  let lines =<< trim END
+    /* Test pressing % on #if, #else #elsif and #endif,
+     * with nested #if
+     */
+    #if FOO
+    /* ... */
+    #  if BAR
+    /* ... */
+    #  endif
+    #elif BAR
+    /* ... */
+    #else
+    /* ... */
+    #endif
+
+    #define FOO 1
+  END
+  call setline(1, lines)
   /#if FOO
   norm %
   call assert_equal([9, 1], getpos('.')[1:2])
@@ -363,6 +366,30 @@ func Test_motion_if_elif_else_endif()
   norm $%
   call assert_equal([6, 1], getpos('.')[1:2])
 
+  " Test for [# and ]# command
+  call cursor(5, 1)
+  normal [#
+  call assert_equal([4, 1], getpos('.')[1:2])
+  call cursor(5, 1)
+  normal ]#
+  call assert_equal([9, 1], getpos('.')[1:2])
+  call cursor(10, 1)
+  normal [#
+  call assert_equal([9, 1], getpos('.')[1:2])
+  call cursor(10, 1)
+  normal ]#
+  call assert_equal([11, 1], getpos('.')[1:2])
+
+  " Finding a match before the first line or after the last line should fail
+  normal gg
+  call assert_beeps('normal [#')
+  normal G
+  call assert_beeps('normal ]#')
+
+  " Finding a match for a macro definition (#define) should fail
+  normal G
+  call assert_beeps('normal %')
+
   bw!
 endfunc
 
@@ -392,3 +419,5 @@ func Test_motion_c_comment()
 
   bw!
 endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab