1" Tests for startup using utf-8.
2
3source check.vim
4source shared.vim
5source screendump.vim
6
7func Test_read_stdin_utf8()
8  let linesin = ['テスト', '€ÀÈÌÒÙ']
9  call writefile(linesin, 'Xtestin')
10  let before = [
11	\ 'set enc=utf-8',
12	\ 'set fencs=cp932,utf-8',
13	\ ]
14  let after = [
15	\ 'write ++enc=utf-8 Xtestout',
16	\ 'quit!',
17	\ ]
18  if has('win32')
19    let pipecmd = 'type Xtestin | '
20  else
21    let pipecmd = 'cat Xtestin | '
22  endif
23  if RunVimPiped(before, after, '-', pipecmd)
24    let lines = readfile('Xtestout')
25    call assert_equal(linesin, lines)
26  else
27    call assert_equal('', 'RunVimPiped failed.')
28  endif
29  call delete('Xtestout')
30  call delete('Xtestin')
31endfunc
32
33func Test_read_fifo_utf8()
34  if !has('unix')
35    return
36  endif
37  " Using bash/zsh's process substitution.
38  if executable('bash')
39    set shell=bash
40  elseif executable('zsh')
41    set shell=zsh
42  else
43    return
44  endif
45  let linesin = ['テスト', '€ÀÈÌÒÙ']
46  call writefile(linesin, 'Xtestin')
47  let before = [
48	\ 'set enc=utf-8',
49	\ 'set fencs=cp932,utf-8',
50	\ ]
51  let after = [
52	\ 'write ++enc=utf-8 Xtestout',
53	\ 'quit!',
54	\ ]
55  if RunVim(before, after, '<(cat Xtestin)')
56    let lines = readfile('Xtestout')
57    call assert_equal(linesin, lines)
58  else
59    call assert_equal('', 'RunVim failed.')
60  endif
61  call delete('Xtestout')
62  call delete('Xtestin')
63endfunc
64
65func Test_detect_ambiwidth()
66  CheckRunVimInTerminal
67
68  " Use the title termcap entries to output the escape sequence.
69  call writefile([
70	\ 'set enc=utf-8',
71	\ 'set ambiwidth=double',
72	\ 'call test_option_not_set("ambiwidth")',
73	\ 'redraw',
74	\ ], 'Xscript')
75  let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1})
76  call TermWait(buf)
77  call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>")
78  call WaitForAssert({-> assert_match('single', term_getline(buf, 1))})
79
80  call StopVimInTerminal(buf)
81  call delete('Xscript')
82endfunc
83