Bram Moolenaar | 2c7292d | 2017-03-05 17:43:31 +0100 | [diff] [blame] | 1 | " Tests for 'makeencoding'. |
Bram Moolenaar | 2c7292d | 2017-03-05 17:43:31 +0100 | [diff] [blame] | 2 | |
| 3 | source shared.vim |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 4 | source check.vim |
Bram Moolenaar | 2c7292d | 2017-03-05 17:43:31 +0100 | [diff] [blame] | 5 | |
Bram Moolenaar | 5a4c308 | 2019-12-01 15:23:11 +0100 | [diff] [blame] | 6 | CheckFeature quickfix |
Bram Moolenaar | 2c7292d | 2017-03-05 17:43:31 +0100 | [diff] [blame] | 7 | let s:python = PythonProg() |
| 8 | if s:python == '' |
Bram Moolenaar | b46fecd | 2019-06-15 17:58:09 +0200 | [diff] [blame] | 9 | throw 'Skipped: python program missing' |
Bram Moolenaar | 2c7292d | 2017-03-05 17:43:31 +0100 | [diff] [blame] | 10 | endif |
| 11 | |
| 12 | let s:script = 'test_makeencoding.py' |
| 13 | |
| 14 | let s:message_tbl = { |
| 15 | \ 'utf-8': 'ÀÈÌÒÙ こんにちは 你好', |
| 16 | \ 'latin1': 'ÀÈÌÒÙ', |
| 17 | \ 'cp932': 'こんにちは', |
| 18 | \ 'cp936': '你好', |
| 19 | \} |
| 20 | |
| 21 | |
| 22 | " Tests for :cgetfile and :lgetfile. |
| 23 | func Test_getfile() |
| 24 | set errorfile=Xerror.txt |
| 25 | set errorformat=%f(%l)\ :\ %m |
| 26 | |
| 27 | " :cgetfile |
| 28 | for enc in keys(s:message_tbl) |
| 29 | let &makeencoding = enc |
| 30 | exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile |
| 31 | cgetfile |
| 32 | copen |
| 33 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 34 | \ getline('.')) |
| 35 | cclose |
| 36 | endfor |
| 37 | |
| 38 | " :lgetfile |
| 39 | for enc in keys(s:message_tbl) |
| 40 | let &makeencoding = enc |
| 41 | exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile |
| 42 | lgetfile |
| 43 | lopen |
| 44 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 45 | \ getline('.')) |
| 46 | lclose |
| 47 | endfor |
| 48 | |
| 49 | call delete(&errorfile) |
| 50 | endfunc |
| 51 | |
| 52 | |
| 53 | " Tests for :grep and :lgrep. |
| 54 | func Test_grep() |
| 55 | let &grepprg = s:python |
| 56 | set grepformat=%f(%l)\ :\ %m |
| 57 | |
| 58 | " :grep |
| 59 | for enc in keys(s:message_tbl) |
| 60 | let &makeencoding = enc |
| 61 | exec "silent grep! " . s:script . " " . enc |
| 62 | copen |
| 63 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 64 | \ getline('.')) |
| 65 | cclose |
| 66 | endfor |
| 67 | |
| 68 | " :lgrep |
| 69 | for enc in keys(s:message_tbl) |
| 70 | let &makeencoding = enc |
| 71 | exec "silent lgrep! " . s:script . " " . enc |
| 72 | lopen |
| 73 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 74 | \ getline('.')) |
| 75 | lclose |
| 76 | endfor |
| 77 | endfunc |
| 78 | |
| 79 | |
| 80 | " Tests for :make and :lmake. |
| 81 | func Test_make() |
| 82 | let &makeprg = s:python |
| 83 | set errorformat=%f(%l)\ :\ %m |
| 84 | |
| 85 | " :make |
| 86 | for enc in keys(s:message_tbl) |
| 87 | let &makeencoding = enc |
| 88 | exec "silent make! " . s:script . " " . enc |
| 89 | copen |
| 90 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 91 | \ getline('.')) |
| 92 | cclose |
| 93 | endfor |
| 94 | |
| 95 | " :lmake |
| 96 | for enc in keys(s:message_tbl) |
| 97 | let &makeencoding = enc |
| 98 | exec "silent lmake! " . s:script . " " . enc |
| 99 | lopen |
| 100 | call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", |
| 101 | \ getline('.')) |
| 102 | lclose |
| 103 | endfor |
| 104 | endfunc |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 105 | |
| 106 | " vim: shiftwidth=2 sts=2 expandtab |