diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-03-27 15:13:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-03-27 15:13:38 +0200 |
commit | ea6553bec340920d8a09c7210cdc2d218e25ace2 (patch) | |
tree | 6055474156b2f2b4a008e01b1f4353642e2f3b69 /src/testdir/test_assert.vim | |
parent | 4f3f668c8486444e53163c29d2fc79bf47eb3c82 (diff) | |
download | vim-ea6553bec340920d8a09c7210cdc2d218e25ace2.zip |
patch 7.4.1663
Problem: In tests it's often useful to check if a pattern matches.
Solution: Add assert_match().
Diffstat (limited to 'src/testdir/test_assert.vim')
-rw-r--r-- | src/testdir/test_assert.vim | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index 2ac828b28..bc025b4c4 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -57,14 +57,26 @@ func Test_compare_fail() call assert_equal(s:w, '') catch call assert_exception('E724:') - call assert_true(v:errors[0] =~ "Expected NULL but got ''") + call assert_match("Expected NULL but got ''", v:errors[0]) call remove(v:errors, 0) endtry endfunc +func Test_match() + call assert_match('^f.*b.*r$', 'foobar') + + call assert_match('bar.*foo', 'foobar') + call assert_match("Pattern 'bar.*foo' does not match 'foobar'", v:errors[0]) + call remove(v:errors, 0) + + call assert_match('bar.*foo', 'foobar', 'wrong') + call assert_match('wrong', v:errors[0]) + call remove(v:errors, 0) +endfunc + func Test_assert_fail_fails() call assert_fails('xxx', {}) - call assert_true(v:errors[0] =~ "Expected {} but got 'E731:") + call assert_match("Expected {} but got 'E731:", v:errors[0]) call remove(v:errors, 0) endfunc |