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