diff src/testdir/test_put.vim @ 26137:14a55d1520f2 v8.2.3601

patch 8.2.3601: check for overflow in put count does not work well Commit: https://github.com/vim/vim/commit/fa53722367c3793fda95dac665af74b8651065e9 Author: ichizok <gclient.gaap@gmail.com> Date: Tue Nov 16 12:50:46 2021 +0000 patch 8.2.3601: check for overflow in put count does not work well Problem: Check for overflow in put count does not work well. Solution: Improve the overflow check. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/9102)
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Nov 2021 14:00:04 +0100
parents e353ace59e62
children 164db42130ec
line wrap: on
line diff
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -149,8 +149,16 @@ func Test_p_with_count_leaves_mark_at_en
 endfunc
 
 func Test_very_large_count()
-  if v:sizeofint != 8
-    throw 'Skipped: only works with 64 bit ints'
+  new
+  " total put-length (21474837 * 100) brings 32 bit int overflow
+  let @" = repeat('x', 100)
+  call assert_fails('norm 21474837p', 'E1240:')
+  bwipe!
+endfunc
+
+func Test_very_large_count_64bit()
+  if v:sizeoflong < 8
+    throw 'Skipped: only works with 64 bit long ints'
   endif
 
   new
@@ -159,6 +167,27 @@ func Test_very_large_count()
   bwipe!
 endfunc
 
+func Test_very_large_count_block()
+  new
+  " total put-length (21474837 * 100) brings 32 bit int overflow
+  call setline(1, repeat('x', 100))
+  exe "norm \<C-V>99ly"
+  call assert_fails('norm 21474837p', 'E1240:')
+  bwipe!
+endfunc
+
+func Test_very_large_count_block_64bit()
+  if v:sizeoflong < 8
+    throw 'Skipped: only works with 64 bit long ints'
+  endif
+
+  new
+  call setline(1, 'x')
+  exe "norm \<C-V>y"
+  call assert_fails('norm 44444444444444p', 'E1240:')
+  bwipe!
+endfunc
+
 func Test_put_above_first_line()
   new
   let @" = 'text'