blob: d78ac8e8f82f13cb45e7d8f27317461d8d1bf876 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Test for shortpathname ':8' extension.
2Only for use on Win32 systems!
3
4STARTTEST
5:so small.vim
6:fun! TestIt(file, bits, expected)
7 let res=fnamemodify(a:file,a:bits)
8 if a:expected == ''
9 echo "'".a:file."'->(".a:bits.")->'".res."'"
10 else
11 if substitute(res,'/','\\', 'g') != substitute( a:expected, '/','\\', 'g')
12 echo "FAILED: '".a:file."'->(".a:bits.")->'".res."'"
13 echo "Expected: '".a:expected."'"
14 else
15 echo "OK"
16 endif
17 endif
18endfun
19:fun! MakeDir( dirname )
20 "exe '!mkdir '.substitute(a:dirname,'/','\\','g')
21 call system('mkdir '.substitute(a:dirname,'/','\\','g'))
22endfun
23:fun! RMDir( dirname)
24 "exe '!rmdir '.substitute(a:dirname,'/','\\','g')
25 call system('rmdir '.substitute(a:dirname,'/','\\','g'))
26endfun
27:fun! MakeFile( filename)
28 "exe '!copy nul '.substitute(a:filename,'/','\\','g')
29 call system('copy nul '.substitute(a:filename,'/','\\','g'))
30endfun
31:fun! TestColonEight()
32 redir! >test.out
33 " This could change for CygWin to //cygdrive/c
34 let dir1='c:/x.x.y'
35 if filereadable(dir1) || isdirectory(dir1)
36 call confirm( "'".dir1."' exists, cannot run test" )
37 return
38 endif
39 let file1=dir1.'/zz.y.txt'
40 let nofile1=dir1.'/z.y.txt'
41 let dir2=dir1.'/VimIsTheGreatestSinceSlicedBread'
42 let file2=dir2.'/z.txt'
43 let nofile2=dir2.'/zz.txt'
44 let resdir1='c:/XX2235~1.Y'
45 let resfile1=resdir1.'/ZZY~1.TXT'
46 let resnofile1=resdir1.'/z.y.txt'
47 let resdir2=resdir1.'/VIMIST~1'
48 let resfile2=resdir2.'/z.txt'
49 let resnofile2=resdir2.'/zz.txt'
50 call MakeDir( dir1 )
51 call MakeDir( dir2 )
52 call MakeFile( file1 )
53 call MakeFile( file2 )
54 call TestIt(file1, ':p:8', resfile1)
55 call TestIt(nofile1, ':p:8', resnofile1)
56 call TestIt(file2, ':p:8', resfile2)
57 call TestIt(nofile2, ':p:8', resnofile2)
58 call TestIt(nofile2, ':p:8:h', fnamemodify(resnofile2,':h'))
59 exe 'cd '.dir1
60 call TestIt(file1, ':.:8', strpart(resfile1,strlen(resdir1)+1))
61 call TestIt(nofile1, ':.:8', strpart(resnofile1,strlen(resdir1)+1))
62 call TestIt(file2, ':.:8', strpart(resfile2,strlen(resdir1)+1))
63 call TestIt(nofile2, ':.:8', strpart(resnofile2,strlen(resdir1)+1))
64 let $HOME=dir1
65 call TestIt(file1, ':~:8', '~'.strpart(resfile1,strlen(resdir1)))
66 call TestIt(nofile1, ':~:8', '~'.strpart(resnofile1,strlen(resdir1)))
67 call TestIt(file2, ':~:8', '~'.strpart(resfile2,strlen(resdir1)))
68 call TestIt(nofile2, ':~:8', '~'.strpart(resnofile2,strlen(resdir1)))
69 cd c:/
70 call delete( file2 )
71 call delete( file1 )
72 call RMDir( dir2 )
73 call RMDir( dir1 )
74 echo
75 redir END
76endfun
77:let dir = getcwd()
78:call TestColonEight()
79:exe "cd " . dir
80:edit! test.out
81:set ff=dos
82:w
83:qa!
84ENDTEST
85