view src/testdir/test_shortpathname.vim @ 17089:8e9e9124c7a2 v8.1.1544

patch 8.1.1544: some balloon tests don't run when they can commit https://github.com/vim/vim/commit/b46fecd3454399f8ebdc5055302e4bfc5a10f98b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 15 17:58:09 2019 +0200 patch 8.1.1544: some balloon tests don't run when they can Problem: Some balloon tests don't run when they can. Solution: Split GUI balloon tests off into a separate file. (Ozaki Kiichi, closes #4538) Change the feature check into a command for consistency.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Jun 2019 18:00:08 +0200
parents f38fcbf343ce
children 403ac78df9a0
line wrap: on
line source

" Test for shortpathname ':8' extension.
" Only for use on Win32 systems!

if !has('win32')
  throw 'Skipped: not on MS-Windows'
endif

func TestIt(file, bits, expected)
  let res = fnamemodify(a:file, a:bits)
  if a:expected != ''
    call assert_equal(substitute(a:expected, '/', '\\', 'g'),
		\ substitute(res, '/', '\\', 'g'),
		\ "'" . a:file . "'->(" . a:bits . ")->'" . res . "'")
  endif
endfunc

func Test_ColonEight()
  let save_dir = getcwd()

  " This could change for CygWin to //cygdrive/c
  let dir1 = 'c:/x.x.y'
  if filereadable(dir1) || isdirectory(dir1)
    call assert_report("Fatal: '" . dir1 . "' exists, cannot run test")
    return
  endif

  let file1 = dir1 . '/zz.y.txt'
  let nofile1 = dir1 . '/z.y.txt'
  let dir2 = dir1 . '/VimIsTheGreatestSinceSlicedBread'
  let file2 = dir2 . '/z.txt'
  let nofile2 = dir2 . '/zz.txt'

  call mkdir(dir1)
  let resdir1 = substitute(fnamemodify(dir1, ':p:8'), '/$', '', '')
  call assert_match('\V\^c:/XX\x\x\x\x~1.Y\$', resdir1)

  let resfile1 = resdir1 . '/ZZY~1.TXT'
  let resnofile1 = resdir1 . '/z.y.txt'
  let resdir2 = resdir1 . '/VIMIST~1'
  let resfile2 = resdir2 . '/z.txt'
  let resnofile2 = resdir2 . '/zz.txt'

  call mkdir(dir2)
  call writefile([], file1)
  call writefile([], file2)

  call TestIt(file1, ':p:8', resfile1)
  call TestIt(nofile1, ':p:8', resnofile1)
  call TestIt(file2, ':p:8', resfile2)
  call TestIt(nofile2, ':p:8', resnofile2)
  call TestIt(nofile2, ':p:8:h', fnamemodify(resnofile2, ':h'))
  exe 'cd ' . dir1
  call TestIt(file1, ':.:8', strpart(resfile1, strlen(resdir1)+1))
  call TestIt(nofile1, ':.:8', strpart(resnofile1, strlen(resdir1)+1))
  call TestIt(file2, ':.:8', strpart(resfile2, strlen(resdir1)+1))
  call TestIt(nofile2, ':.:8', strpart(resnofile2, strlen(resdir1)+1))
  let $HOME=dir1
  call TestIt(file1, ':~:8', '~' . strpart(resfile1, strlen(resdir1)))
  call TestIt(nofile1, ':~:8', '~' . strpart(resnofile1, strlen(resdir1)))
  call TestIt(file2, ':~:8', '~' . strpart(resfile2, strlen(resdir1)))
  call TestIt(nofile2, ':~:8', '~' . strpart(resnofile2, strlen(resdir1)))

  cd c:/
  call delete(file2)
  call delete(file1)
  call delete(dir2, 'd')
  call delete(dir1, 'd')

  exe "cd " . save_dir
endfunc