view src/testdir/test_startup_utf8.vim @ 19783:546bdeef35f1 v8.2.0448

patch 8.2.0448: various functions not properly tested Commit: https://github.com/vim/vim/commit/0e05de46226eb4e5ea580beefa71831f92d613d3 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 25 22:23:46 2020 +0100 patch 8.2.0448: various functions not properly tested Problem: Various functions not properly tested. Solution: Add more tests, especially for failures. (Yegappan Lakshmanan, closes #5843)
author Bram Moolenaar <Bram@vim.org>
date Wed, 25 Mar 2020 22:30:04 +0100
parents ba7727889385
children c087099e9163
line wrap: on
line source

" Tests for startup using utf-8.

source shared.vim
source screendump.vim

func Test_read_stdin_utf8()
  let linesin = ['テスト', '€ÀÈÌÒÙ']
  call writefile(linesin, 'Xtestin')
  let before = [
	\ 'set enc=utf-8',
	\ 'set fencs=cp932,utf-8',
	\ ]
  let after = [
	\ 'write ++enc=utf-8 Xtestout',
	\ 'quit!',
	\ ]
  if has('win32')
    let pipecmd = 'type Xtestin | '
  else
    let pipecmd = 'cat Xtestin | '
  endif
  if RunVimPiped(before, after, '-', pipecmd)
    let lines = readfile('Xtestout')
    call assert_equal(linesin, lines)
  else
    call assert_equal('', 'RunVimPiped failed.')
  endif
  call delete('Xtestout')
  call delete('Xtestin')
endfunc

func Test_read_fifo_utf8()
  if !has('unix')
    return
  endif
  " Using bash/zsh's process substitution.
  if executable('bash')
    set shell=bash
  elseif executable('zsh')
    set shell=zsh
  else
    return
  endif
  let linesin = ['テスト', '€ÀÈÌÒÙ']
  call writefile(linesin, 'Xtestin')
  let before = [
	\ 'set enc=utf-8',
	\ 'set fencs=cp932,utf-8',
	\ ]
  let after = [
	\ 'write ++enc=utf-8 Xtestout',
	\ 'quit!',
	\ ]
  if RunVim(before, after, '<(cat Xtestin)')
    let lines = readfile('Xtestout')
    call assert_equal(linesin, lines)
  else
    call assert_equal('', 'RunVim failed.')
  endif
  call delete('Xtestout')
  call delete('Xtestin')
endfunc

func Test_detect_ambiwidth()
  if !CanRunVimInTerminal()
    throw 'Skipped: cannot run Vim in a terminal window'
  endif

  " Use the title termcap entries to output the escape sequence.
  call writefile([
	\ 'set enc=utf-8',
	\ 'set ambiwidth=double',
	\ 'call test_option_not_set("ambiwidth")',
	\ 'redraw',
	\ ], 'Xscript')
  let buf = RunVimInTerminal('-S Xscript', {})
  call term_wait(buf)
  call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>")
  call WaitForAssert({-> assert_match('single', term_getline(buf, 1))})

  call StopVimInTerminal(buf)
  call delete('Xscript')
endfunc