comparison src/testdir/test_functions.vim @ 12451:61450cb2b6a1 v8.0.1105

patch 8.0.1105: match() and matchend() are not tested commit https://github.com/vim/vim/commit/1190cf68e27a123cf9f6fb57897782a3b9f7b810 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 14 14:31:18 2017 +0200 patch 8.0.1105: match() and matchend() are not tested Problem: match() and matchend() are not tested. Solution: Add tests. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2088)
author Christian Brabandt <cb@256bit.org>
date Thu, 14 Sep 2017 14:45:04 +0200
parents 5a07a3ff56c1
children a89350ba2a9d
comparison
equal deleted inserted replaced
12450:1c02d9d87d59 12451:61450cb2b6a1
526 call assert_equal(-1, strridx('hello', 'l', -1)) 526 call assert_equal(-1, strridx('hello', 'l', -1))
527 call assert_equal(2, strridx('hello', 'll')) 527 call assert_equal(2, strridx('hello', 'll'))
528 call assert_equal(-1, strridx('hello', 'hello world')) 528 call assert_equal(-1, strridx('hello', 'hello world'))
529 endfunc 529 endfunc
530 530
531 func Test_match_func()
532 call assert_equal(4, match('testing', 'ing'))
533 call assert_equal(4, match('testing', 'ing', 2))
534 call assert_equal(-1, match('testing', 'ing', 5))
535 call assert_equal(-1, match('testing', 'ing', 8))
536 call assert_equal(1, match(['vim', 'testing', 'execute'], 'ing'))
537 call assert_equal(-1, match(['vim', 'testing', 'execute'], 'img'))
538 endfunc
539
531 func Test_matchend() 540 func Test_matchend()
532 call assert_equal(7, matchend('testing', 'ing')) 541 call assert_equal(7, matchend('testing', 'ing'))
533 call assert_equal(7, matchend('testing', 'ing', 2)) 542 call assert_equal(7, matchend('testing', 'ing', 2))
534 call assert_equal(-1, matchend('testing', 'ing', 5)) 543 call assert_equal(-1, matchend('testing', 'ing', 5))
544 call assert_equal(-1, matchend('testing', 'ing', 8))
545 call assert_equal(match(['vim', 'testing', 'execute'], 'ing'), matchend(['vim', 'testing', 'execute'], 'ing'))
546 call assert_equal(match(['vim', 'testing', 'execute'], 'img'), matchend(['vim', 'testing', 'execute'], 'img'))
547 endfunc
548
549 func Test_matchlist()
550 call assert_equal(['acd', 'a', '', 'c', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)'))
551 call assert_equal(['d', '', '', '', 'd', '', '', '', '', ''], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 2))
552 call assert_equal([], matchlist('acd', '\(a\)\?\(b\)\?\(c\)\?\(.*\)', 4))
553 endfunc
554
555 func Test_matchstr()
556 call assert_equal('ing', matchstr('testing', 'ing'))
557 call assert_equal('ing', matchstr('testing', 'ing', 2))
558 call assert_equal('', matchstr('testing', 'ing', 5))
559 call assert_equal('', matchstr('testing', 'ing', 8))
560 call assert_equal('testing', matchstr(['vim', 'testing', 'execute'], 'ing'))
561 call assert_equal('', matchstr(['vim', 'testing', 'execute'], 'img'))
562 endfunc
563
564 func Test_matchstrpos()
565 call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing'))
566 call assert_equal(['ing', 4, 7], matchstrpos('testing', 'ing', 2))
567 call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 5))
568 call assert_equal(['', -1, -1], matchstrpos('testing', 'ing', 8))
569 call assert_equal(['ing', 1, 4, 7], matchstrpos(['vim', 'testing', 'execute'], 'ing'))
570 call assert_equal(['', -1, -1, -1], matchstrpos(['vim', 'testing', 'execute'], 'img'))
535 endfunc 571 endfunc
536 572
537 func Test_nextnonblank_prevnonblank() 573 func Test_nextnonblank_prevnonblank()
538 new 574 new
539 insert 575 insert