blob: 6f09e85a42a999bc7fd10cb2506c4cc12786b8e5 [file] [log] [blame]
Bram Moolenaarcd055da2016-09-02 19:50:48 +02001
Bram Moolenaar1e115362019-01-09 23:01:02 +01002func Test_charsearch()
Bram Moolenaarcd055da2016-09-02 19:50:48 +02003 enew!
4 call append(0, ['Xabcdefghijkemnopqretuvwxyz',
Bram Moolenaar53f16732016-09-07 20:46:39 +02005 \ 'Yabcdefghijkemnopqretuvwxyz',
6 \ 'Zabcdefghijkemnokqretkvwxyz'])
Bram Moolenaarcd055da2016-09-02 19:50:48 +02007 " check that "fe" and ";" work
8 1
9 normal! ylfep;;p,,p
10 call assert_equal('XabcdeXfghijkeXmnopqreXtuvwxyz', getline(1))
11 " check that save/restore works
12 2
13 normal! ylfep
14 let csave = getcharsearch()
15 normal! fip
16 call setcharsearch(csave)
17 normal! ;p;p
18 call assert_equal('YabcdeYfghiYjkeYmnopqreYtuvwxyz', getline(2))
19
20 " check that setcharsearch() changes the settings.
21 3
22 normal! ylfep
Bram Moolenaar196b4662019-09-06 21:34:30 +020023 eval {'char': 'k'}->setcharsearch()
Bram Moolenaarcd055da2016-09-02 19:50:48 +020024 normal! ;p
25 call setcharsearch({'forward': 0})
26 normal! $;p
27 call setcharsearch({'until': 1})
28 set cpo-=;
29 normal! ;;p
30 call assert_equal('ZabcdeZfghijkZZemnokqretkZvwxyz', getline(3))
31 enew!
Bram Moolenaar1e115362019-01-09 23:01:02 +010032endfunc
Bram Moolenaarcd055da2016-09-02 19:50:48 +020033
34" Test for t,f,F,T movement commands and 'cpo-;' setting
Bram Moolenaar1e115362019-01-09 23:01:02 +010035func Test_search_cmds()
Bram Moolenaarcd055da2016-09-02 19:50:48 +020036 enew!
37 call append(0, ["aaa two three four", " zzz", "yyy ",
38 \ "bbb yee yoo four", "ccc two three four",
39 \ "ddd yee yoo four"])
40 set cpo-=;
41 1
42 normal! 0tt;D
43 2
44 normal! 0fz;D
45 3
46 normal! $Fy;D
47 4
48 normal! $Ty;D
49 set cpo+=;
50 5
51 normal! 0tt;;D
52 6
53 normal! $Ty;;D
54
55 call assert_equal('aaa two', getline(1))
56 call assert_equal(' z', getline(2))
57 call assert_equal('y', getline(3))
58 call assert_equal('bbb y', getline(4))
59 call assert_equal('ccc', getline(5))
60 call assert_equal('ddd yee y', getline(6))
61 enew!
Bram Moolenaar1e115362019-01-09 23:01:02 +010062endfunc