diff src/testdir/test_quickfix.vim @ 7513:37e061ec063c v7.4.1058

commit https://github.com/vim/vim/commit/75bdf6aa30a5c99d67c42886cf7a4a000bbaa422 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 7 21:25:08 2016 +0100 patch 7.4.1058 Problem: It is not possible to test code that is only reached when memory allocation fails. Solution: Add the alloc_fail() function. Try it out with :vimgrep.
author Christian Brabandt <cb@256bit.org>
date Thu, 07 Jan 2016 21:30:05 +0100
parents 3e306ae760d0
children b910bb01832a
line wrap: on
line diff
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -273,3 +273,42 @@ function Test_cbuffer()
   call XbufferTests('l')
 endfunction
 
+function Test_nomem()
+  call alloc_fail(1, 0, 0)
+  try
+    vimgrep vim runtest.vim
+  catch
+    call assert_true(v:exception =~ 'E342')
+  endtry
+
+  call alloc_fail(2, 0, 0)
+  try
+    vimgrep vim runtest.vim
+  catch
+    call assert_true(v:exception =~ 'E342')
+  endtry
+
+  call alloc_fail(3, 0, 0)
+  try
+    cfile runtest.vim
+  catch
+    call assert_true(v:exception =~ 'E342')
+  endtry
+
+  call alloc_fail(4, 0, 0)
+  try
+    cfile runtest.vim
+  catch
+    call assert_true(v:exception =~ 'E342')
+  endtry
+
+  call alloc_fail(5, 0, 0)
+  try
+    cfile runtest.vim
+  catch
+    call assert_true(v:exception =~ 'E342')
+  endtry
+
+endfunc
+
+