1" Test for character search commands - t, T, f, F, ; and , 2 3func Test_charsearch() 4 enew! 5 call append(0, ['Xabcdefghijkemnopqretuvwxyz', 6 \ 'Yabcdefghijkemnopqretuvwxyz', 7 \ 'Zabcdefghijkemnokqretkvwxyz']) 8 " check that "fe" and ";" work 9 1 10 normal! ylfep;;p,,p 11 call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1)) 12 " check that save/restore works 13 2 14 normal! ylfep 15 let csave = getcharsearch() 16 normal! fip 17 call setcharsearch(csave) 18 normal! ;p;p 19 call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2)) 20 21 " check that setcharsearch() changes the settings. 22 3 23 normal! ylfep 24 eval {'char': 'k'}->setcharsearch() 25 normal! ;p 26 call setcharsearch({'forward': 0}) 27 normal! $;p 28 call setcharsearch({'until': 1}) 29 set cpo-=; 30 normal! ;;p 31 call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3)) 32 33 " check that repeating a search before and after a line fails 34 normal 3Gfv 35 call assert_beeps('normal ;') 36 call assert_beeps('normal ,') 37 38 " clear the character search 39 call setcharsearch({'char' : ''}) 40 call assert_equal('', getcharsearch().char) 41 42 call assert_fails("call setcharsearch([])", 'E715:') 43 enew! 44endfunc 45 46" Test for t,f,F,T movement commands and 'cpo-;' setting 47func Test_search_cmds() 48 enew! 49 call append(0, ["aaa two three four", " zzz", "yyy ", 50 \ "bbb yee yoo four", "ccc two three four", 51 \ "ddd yee yoo four"]) 52 set cpo-=; 53 1 54 normal! 0tt;D 55 2 56 normal! 0fz;D 57 3 58 normal! $Fy;D 59 4 60 normal! $Ty;D 61 set cpo+=; 62 5 63 normal! 0tt;;D 64 6 65 normal! $Ty;;D 66 67 call assert_equal('aaa two', getline(1)) 68 call assert_equal(' z', getline(2)) 69 call assert_equal('y', getline(3)) 70 call assert_equal('bbb y', getline(4)) 71 call assert_equal('ccc', getline(5)) 72 call assert_equal('ddd yee y', getline(6)) 73 enew! 74endfunc 75 76" Test for character search in virtual edit mode with <Tab> 77func Test_csearch_virtualedit() 78 new 79 set virtualedit=all 80 call setline(1, "a\tb") 81 normal! tb 82 call assert_equal([0, 1, 2, 6], getpos('.')) 83 set virtualedit& 84 close! 85endfunc 86 87" Test for character search failure in latin1 encoding 88func Test_charsearch_latin1() 89 new 90 let save_enc = &encoding 91 set encoding=latin1 92 call setline(1, 'abcdefghijk') 93 call assert_beeps('normal fz') 94 call assert_beeps('normal tx') 95 call assert_beeps('normal $Fz') 96 call assert_beeps('normal $Tx') 97 let &encoding = save_enc 98 close! 99endfunc 100 101" vim: shiftwidth=2 sts=2 expandtab 102