diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-09-14 14:31:18 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-09-14 14:31:18 +0200 |
commit | 1190cf68e27a123cf9f6fb57897782a3b9f7b810 (patch) | |
tree | b8fa118ac9f956d913fd8202707a0e2b95f34b6b /src | |
parent | ef6b8de42f439271edcf5cf22b2450f2cf302c2e (diff) | |
download | vim-1190cf68e27a123cf9f6fb57897782a3b9f7b810.zip |
patch 8.0.1105: match() and matchend() are not tested
Problem: match() and matchend() are not tested.
Solution: Add tests. (Ozaki Kiichi, closes #2088)
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_functions.vim | 36 | ||||
-rw-r--r-- | src/testdir/test_match.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 39 insertions, 10 deletions
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim index ac47ea1da..bdc738826 100644 --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -528,10 +528,46 @@ func Test_strridx() call assert_equal(-1, strridx('hello', 'hello world')) endfunc +func Test_match_func() + call assert_equal(4, match('testing', 'ing')) + call assert_equal(4, match('testing', 'ing', 2)) + call assert_equal(-1, match('testing', 'ing', 5)) + call assert_equal(-1, match('testing', 'ing', 8)) + call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing')) + call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img')) +endfunc + func Test_matchend() call assert_equal(7, matchend('testing', 'ing')) call assert_equal(7, matchend('testing', 'ing', 2)) call assert_equal(-1, matchend('testing', 'ing', 5)) + call assert_equal(-1, matchend('testing', 'ing', 8)) + call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing')) + call assert_equal(match(['vim', 'testing', 'execute'], 'img'), matchend(['vim', 'testing', 'execute'], 'img')) +endfunc + +func Test_matchlist() + call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)')) + call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2)) + call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4)) +endfunc + +func Test_matchstr() + call assert_equal('ing', matchstr('testing', 'ing')) + call assert_equal('ing', matchstr('testing', 'ing', 2)) + call assert_equal('', matchstr('testing', 'ing', 5)) + call assert_equal('', matchstr('testing', 'ing', 8)) + call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing')) + call assert_equal('', matchstr(['vim', 'testing', 'execute'], 'img')) +endfunc + +func Test_matchstrpos() + call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing')) + call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2)) + call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5)) + call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8)) + call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing')) + call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img')) endfunc func Test_nextnonblank_prevnonblank() diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim index a78883a59..28dd97c92 100644 --- a/src/testdir/test_match.vim +++ b/src/testdir/test_match.vim @@ -1,5 +1,5 @@ " Test for :match, :2match, :3match, clearmatches(), getmatches(), matchadd(), -" matchaddpos(), matcharg(), matchdelete(), matchstrpos() and setmatches(). +" matchaddpos(), matcharg(), matchdelete(), and setmatches(). function Test_match() highlight MyGroup1 term=bold ctermbg=red guibg=red @@ -150,15 +150,6 @@ function Test_match() highlight MyGroup3 NONE endfunc -func Test_matchstrpos() - call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing')) - call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2)) - call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5)) - call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8)) - call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing')) - call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img')) -endfunc - func Test_matchaddpos() syntax on set hlsearch diff --git a/src/version.c b/src/version.c index f22546c14..f2e6b87be 100644 --- a/src/version.c +++ b/src/version.c @@ -770,6 +770,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1105, +/**/ 1104, /**/ 1103, |