Mercurial > vim
comparison src/testdir/test_buffer.vim @ 28285:a4aad5142959 v8.2.4668
patch 8.2.4668: buffer allocation failures insufficiently tested
Commit: https://github.com/vim/vim/commit/0dac1ab5791819ee9a496273eea38f69a217ac45
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Apr 2 21:46:19 2022 +0100
patch 8.2.4668: buffer allocation failures insufficiently tested
Problem: Buffer allocation failures insufficiently tested.
Solution: Add tests for memory allocation failures. (Yegappan Lakshmanan,
closes #10064)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 02 Apr 2022 23:00:04 +0200 |
parents | 856b56468157 |
children | cdaff4db7760 |
comparison
equal
deleted
inserted
replaced
28284:6cf79c95cb08 | 28285:a4aad5142959 |
---|---|
428 close | 428 close |
429 call assert_equal('', v:errmsg) | 429 call assert_equal('', v:errmsg) |
430 set maxmem& maxmemtot& | 430 set maxmem& maxmemtot& |
431 endfunc | 431 endfunc |
432 | 432 |
433 " Test for a allocation failure when adding a new buffer | |
434 func Test_buflist_alloc_failure() | |
435 %bw! | |
436 | |
437 edit Xfile1 | |
438 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
439 call assert_fails('edit Xfile2', 'E342:') | |
440 | |
441 " test for bufadd() | |
442 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
443 call assert_fails('call bufadd("Xbuffer")', 'E342:') | |
444 | |
445 " test for setting the arglist | |
446 edit Xfile2 | |
447 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
448 call assert_fails('next Xfile3', 'E342:') | |
449 | |
450 " test for setting the alternate buffer name when writing a file | |
451 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
452 call assert_fails('write Xother', 'E342:') | |
453 call delete('Xother') | |
454 | |
455 " test for creating a buffer using bufnr() | |
456 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
457 call assert_fails("call bufnr('Xnewbuf', v:true)", 'E342:') | |
458 | |
459 " test for renaming buffer using :file | |
460 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
461 call assert_fails('file Xnewfile', 'E342:') | |
462 | |
463 " test for creating a buffer for a popup window | |
464 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
465 call assert_fails('call popup_create("mypop", {})', 'E342:') | |
466 | |
467 if has('terminal') | |
468 " test for creating a buffer for a terminal window | |
469 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
470 call assert_fails('call term_start(&shell)', 'E342:') | |
471 %bw! | |
472 endif | |
473 | |
474 " test for loading a new buffer after wiping out all the buffers | |
475 edit Xfile4 | |
476 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
477 call assert_fails('%bw!', 'E342:') | |
478 | |
479 " test for :checktime loading the buffer | |
480 call writefile(['one'], 'Xfile5') | |
481 if has('unix') | |
482 edit Xfile5 | |
483 " sleep for some time to make sure the timestamp is different | |
484 sleep 200m | |
485 call writefile(['two'], 'Xfile5') | |
486 set autoread | |
487 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
488 call assert_fails('checktime', 'E342:') | |
489 set autoread& | |
490 bw! | |
491 endif | |
492 | |
493 " test for :vimgrep loading a dummy buffer | |
494 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
495 call assert_fails('vimgrep two Xfile5', 'E342:') | |
496 call delete('Xfile5') | |
497 | |
498 " test for quickfix command loading a buffer | |
499 call test_alloc_fail(GetAllocId('buflistnew_bvars'), 0, 0) | |
500 call assert_fails('cexpr "Xfile6:10:Line10"', 'E342:') | |
501 endfunc | |
502 | |
433 " vim: shiftwidth=2 sts=2 expandtab | 503 " vim: shiftwidth=2 sts=2 expandtab |