Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 1 | " Tests for startup using utf-8. |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 2 | |
| 3 | source shared.vim |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 4 | source screendump.vim |
Bram Moolenaar | f71d7b9 | 2016-08-09 22:14:05 +0200 | [diff] [blame] | 5 | |
| 6 | func 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') |
| 30 | endfunc |
| 31 | |
| 32 | func 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') |
| 62 | endfunc |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 63 | |
| 64 | func Test_detect_ambiwidth() |
| 65 | if !CanRunVimInTerminal() |
Bram Moolenaar | 5d30ff1 | 2019-06-06 16:12:12 +0200 | [diff] [blame] | 66 | throw 'Skipped: cannot run Vim in a terminal window' |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 67 | endif |
| 68 | |
| 69 | " Use the title termcap entries to output the escape sequence. |
| 70 | call writefile([ |
| 71 | \ 'set enc=utf-8', |
| 72 | \ 'set ambiwidth=double', |
| 73 | \ 'call test_option_not_set("ambiwidth")', |
| 74 | \ 'redraw', |
| 75 | \ ], 'Xscript') |
| 76 | let buf = RunVimInTerminal('-S Xscript', {}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame^] | 77 | call TermWait(buf) |
Bram Moolenaar | 24839ed | 2018-09-13 20:46:52 +0200 | [diff] [blame] | 78 | call term_sendkeys(buf, "S\<C-R>=&ambiwidth\<CR>\<Esc>") |
| 79 | call WaitForAssert({-> assert_match('single', term_getline(buf, 1))}) |
| 80 | |
| 81 | call StopVimInTerminal(buf) |
| 82 | call delete('Xscript') |
| 83 | endfunc |