blob: 1684d80c8058c70a2548a65f33dfe9cbf788e350 [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
Bram Moolenaara45551a2020-06-09 15:57:37 +02003source check.vim
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02004source shared.vim
Bram Moolenaar24839ed2018-09-13 20:46:52 +02005source screendump.vim
Bram Moolenaarf71d7b92016-08-09 22:14:05 +02006
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
Bram Moolenaar24839ed2018-09-13 20:46:52 +020064
65func Test_detect_ambiwidth()
Bram Moolenaar494e9062020-05-31 21:28:02 +020066 CheckRunVimInTerminal
Bram Moolenaar24839ed2018-09-13 20:46:52 +020067
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')
Bram Moolenaara45551a2020-06-09 15:57:37 +020075 let buf = RunVimInTerminal('-S Xscript', #{keep_t_u7: 1})
Bram Moolenaar6a2c5a72020-04-08 21:50:25 +020076 call TermWait(buf)
Bram Moolenaar24839ed2018-09-13 20:46:52 +020077 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