blob: d5bdfab65237ae0d01650a41e10498bf48c5d624 [file] [log] [blame]
Bram Moolenaar53f16732016-09-07 20:46:39 +02001
2" This is a test if a URL is recognized by "gf", with the cursor before and
3" after the "://". Also test ":\\".
Bram Moolenaar2a79ed22017-05-24 09:51:39 +02004func Test_gf_url()
Bram Moolenaar53f16732016-09-07 20:46:39 +02005 enew!
6 call append(0, [
7 \ "first test for URL://machine.name/tmp/vimtest2a and other text",
8 \ "second test for URL://machine.name/tmp/vimtest2b. And other text",
9 \ "third test for URL:\\\\machine.name\\vimtest2c and other text",
10 \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text"
11 \ ])
12 call cursor(1,1)
13 call search("^first")
14 call search("tmp")
15 call assert_equal("URL://machine.name/tmp/vimtest2a", expand("<cfile>"))
16 call search("^second")
17 call search("URL")
18 call assert_equal("URL://machine.name/tmp/vimtest2b", expand("<cfile>"))
19 if has("ebcdic")
20 set isf=@,240-249,/,.,-,_,+,,,$,:,~,\
21 else
22 set isf=@,48-57,/,.,-,_,+,,,$,:,~,\
23 endif
24 call search("^third")
25 call search("name")
26 call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("<cfile>"))
27 call search("^fourth")
28 call search("URL")
29 call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>"))
30
31 set isf&vim
32 enew!
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020033endfunc
34
35func Test_gF()
36 new
37 call setline(1, ['111', '222', '333', '444'])
38 w! Xfile
39 close
40 new
Bram Moolenaard7aca7a2017-05-24 10:05:56 +020041 call setline(1, ['one', 'Xfile@3', 'three'])
Bram Moolenaar2a79ed22017-05-24 09:51:39 +020042 2
43 call assert_fails('normal gF', 'E37:')
44 call assert_equal(2, getcurpos()[1])
45 w! Xfile2
46 normal gF
47 call assert_equal('Xfile', bufname('%'))
48 call assert_equal(3, getcurpos()[1])
49
50 call delete('Xfile')
51 call delete('Xfile2')
52 bwipe Xfile
53 bwipe Xfile2
54endfunc