diff src/testdir/test_increment.vim @ 20613:9edb439adbea v8.2.0860

patch 8.2.0860: cannot use CTRL-A and CTRL-X on unsigned numbers Commit: https://github.com/vim/vim/commit/aaad995f8384a77a64efba6846c9c4ac99de0953 Author: Bram Moolenaar <Bram@vim.org> Date: Sun May 31 15:08:59 2020 +0200 patch 8.2.0860: cannot use CTRL-A and CTRL-X on unsigned numbers Problem: Cannot use CTRL-A and CTRL-X on unsigned numbers. Solution: Add "unsigned" to 'nrformats'. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/6144)
author Bram Moolenaar <Bram@vim.org>
date Sun, 31 May 2020 15:15:04 +0200
parents b07672d13ff9
children 8e5f991db3b4
line wrap: on
line diff
--- a/src/testdir/test_increment.vim
+++ b/src/testdir/test_increment.vim
@@ -1,4 +1,4 @@
-" Tests for using Ctrl-A/Ctrl-X on visual selections
+" Tests for using Ctrl-A/Ctrl-X
 
 func SetUp()
   new dummy
@@ -796,4 +796,48 @@ func Test_increment_special_char()
   call assert_beeps("normal \<C-X>")
 endfunc
 
+" Try incrementing/decrementing a number when nrformats contains unsigned
+func Test_increment_unsigned()
+  set nrformats+=unsigned
+
+  call setline(1, '0')
+  exec "norm! gg0\<C-X>"
+  call assert_equal('0', getline(1))
+
+  call setline(1, '3')
+  exec "norm! gg010\<C-X>"
+  call assert_equal('0', getline(1))
+
+  call setline(1, '-0')
+  exec "norm! gg0\<C-X>"
+  call assert_equal("-0", getline(1))
+
+  call setline(1, '-11')
+  exec "norm! gg08\<C-X>"
+  call assert_equal('-3', getline(1))
+
+  " NOTE: 18446744073709551615 == 2^64 - 1
+  call setline(1, '18446744073709551615')
+  exec "norm! gg0\<C-A>"
+  call assert_equal('18446744073709551615', getline(1))
+
+  call setline(1, '-18446744073709551615')
+  exec "norm! gg0\<C-A>"
+  call assert_equal('-18446744073709551615', getline(1))
+
+  call setline(1, '-18446744073709551614')
+  exec "norm! gg08\<C-A>"
+  call assert_equal('-18446744073709551615', getline(1))
+
+  call setline(1, '-1')
+  exec "norm! gg0\<C-A>"
+  call assert_equal('-2', getline(1))
+
+  call setline(1, '-3')
+  exec "norm! gg08\<C-A>"
+  call assert_equal('-11', getline(1))
+
+  set nrformats-=unsigned
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab