patch 8.2.0655: search code not sufficiently tested

Problem:    Search code not sufficiently tested.
Solution:   Add more tests. (Yegappan Lakshmanan, closes #5999)
diff --git a/src/testdir/test_goto.vim b/src/testdir/test_goto.vim
index 1248de3..aeca0b4 100644
--- a/src/testdir/test_goto.vim
+++ b/src/testdir/test_goto.vim
@@ -333,21 +333,24 @@
 
 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 @@
   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 @@
 
   bw!
 endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab