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.
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 60cb539..6910a8b 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -273,3 +273,42 @@
   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
+
+