robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
4a0005aee9
master
1" Test for character search commands - t, T, f, F, ; and , 2 3func Test_charsearch () 4enew ! 5call append ( 0 , [ 'Xabcdefghijkemnopqretuvwxyz' , 6 \'Yabcdefghijkemnopqretuvwxyz' , 7 \'Zabcdefghijkemnokqretkvwxyz' ]) 8" check that "fe" and ";" work 91 10normal ! ylfep;;p,,p 11call assert_equal ( 'XabcdeXfghijkeXmnopqreXtuvwxyz' , getline ( 1 )) 12" check that save/restore works 132 14normal ! ylfep 15let csave = getcharsearch () 16normal ! fip 17call setcharsearch ( csave ) 18normal ! ;p;p 19call assert_equal ( 'YabcdeYfghiYjkeYmnopqreYtuvwxyz' , getline ( 2 )) 20 21" check that setcharsearch() changes the settings. 223 23normal ! ylfep 24eval { 'char' : 'k' } ->setcharsearch () 25normal ! ;p 26call setcharsearch ({ 'forward' : 0 }) 27normal ! $;p 28call setcharsearch ({ 'until' : 1 }) 29set cpo -= ; 30normal ! ;;p 31call assert_equal ( 'ZabcdeZfghijkZZemnokqretkZvwxyz' , getline ( 3 )) 32 33" check that repeating a search before and after a line fails 34normal 3Gfv 35call assert_beeps ( 'normal ;' ) 36call assert_beeps ( 'normal ,' ) 37 38" clear the character search 39call setcharsearch ({ 'char' : '' }) 40call assert_equal ( '' , getcharsearch (). char ) 41call assert_beeps ( 'normal ;' ) 42call assert_beeps ( 'normal ,' ) 43 44call assert_fails ( "call setcharsearch([])" , 'E1206:' ) 45enew ! 46endfunc 47 48" Test for character search in virtual edit mode with <Tab> 49func Test_csearch_virtualedit () 50new 51set virtualedit = all 52call setline ( 1 , "a\tb" ) 53normal ! tb 54call assert_equal ([ 0 , 1 , 2 , 6 ], getpos ( '.' )) 55set virtualedit & 56bw ! 57endfunc 58 59" Test for character search failure in latin1 encoding 60func Test_charsearch_latin1 () 61new 62let save_enc = & encoding 63" set encoding=latin1 64call setline ( 1 , 'abcdefghijk' ) 65call assert_beeps ( 'normal fz' ) 66call assert_beeps ( 'normal tx' ) 67call assert_beeps ( 'normal $Fz' ) 68call assert_beeps ( 'normal $Tx' ) 69let & encoding = save_enc 70bw ! 71endfunc 72 73" Test for using character search to find a multibyte character with composing 74" characters. 75func Test_charsearch_composing_char () 76new 77call setline ( 1 , "one two thq\u0328\u0301r\u0328\u0301ree" ) 78call feedkeys ( "fr\u0328\u0301" , 'xt' ) 79call assert_equal ([ 0 , 1 , 16 , 0 , 12 ], getcurpos ()) 80 81" use character search with a multi-byte character followed by a 82" non-composing character 83call setline ( 1 , "abc deȉf ghi" ) 84call feedkeys ( "ggcf\u0209\u0210" , 'xt' ) 85call assert_equal ( "\u0210f ghi" , getline ( 1 )) 86bw ! 87endfunc 88 89" Test for character search with 'hkmap' 90func Test_charsearch_hkmap () 91throw "Skipped: Nvim does not support 'hkmap'" 92new 93set hkmap 94call setline ( 1 , "ùðáâ÷ëòéïçìêöî" ) 95call feedkeys ( "fë" , 'xt' ) 96call assert_equal ([ 0 , 1 , 11 , 0 , 6 ], getcurpos ()) 97set hkmap & 98bw ! 99endfunc 100 101" vim: shiftwidth=2 sts=2 expandtab