diff src/testdir/test_tabpage.vim @ 28289:cdaff4db7760 v8.2.4670

patch 8.2.4670: memory allocation failures for new tab page not tested Commit: https://github.com/vim/vim/commit/72bb47e38f6805050ed6d969f17591bed71f83d4 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Apr 3 11:22:38 2022 +0100 patch 8.2.4670: memory allocation failures for new tab page not tested Problem: Memory allocation failures for new tab page not tested. Solution: Add tests with failing memory allocation. (Yegappan Lakshmanan, closes #10067)
author Bram Moolenaar <Bram@vim.org>
date Sun, 03 Apr 2022 12:30:03 +0200
parents 93f90f2ff4e9
children 13b02c1ea0f7
line wrap: on
line diff
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -852,4 +852,27 @@ func Test_lastused_tabpage()
   tabonly!
 endfunc
 
+" Test for tabpage allocation failure
+func Test_tabpage_alloc_failure()
+  call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0)
+  call assert_fails('tabnew', 'E342:')
+
+  call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0)
+  edit Xfile1
+  call assert_fails('tabedit Xfile2', 'E342:')
+  call assert_equal(1, winnr('$'))
+  call assert_equal(1, tabpagenr('$'))
+  call assert_equal('Xfile1', @%)
+
+  new
+  call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0)
+  call assert_fails('wincmd T', 'E342:')
+  bw!
+
+  call test_alloc_fail(GetAllocId('newtabpage_tvars'), 0, 0)
+  call assert_fails('tab split', 'E342:')
+  call assert_equal(2, winnr('$'))
+  call assert_equal(1, tabpagenr('$'))
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab