forked from aniani/vim
patch 8.1.0959: sorting large numbers is not tested
Problem: Sorting large numbers is not tested and does not work properly.
Solution: Add test. Fix comparing lines with and without a number.
(Dominique Pelle, closes #4017)
This commit is contained in:
@@ -1222,6 +1222,77 @@ func Test_sort_cmd()
|
||||
enew!
|
||||
endfunc
|
||||
|
||||
func Test_sort_large_num()
|
||||
new
|
||||
a
|
||||
-2147483648
|
||||
-2147483647
|
||||
|
||||
-1
|
||||
0
|
||||
1
|
||||
-2147483646
|
||||
2147483646
|
||||
2147483647
|
||||
2147483647
|
||||
-2147483648
|
||||
abc
|
||||
|
||||
.
|
||||
" Numerical sort. Non-numeric lines are ordered before numerical lines.
|
||||
" Ordering of non-numerical is stable.
|
||||
sort n
|
||||
call assert_equal(['',
|
||||
\ 'abc',
|
||||
\ '',
|
||||
\ '-2147483648',
|
||||
\ '-2147483648',
|
||||
\ '-2147483647',
|
||||
\ '-2147483646',
|
||||
\ '-1',
|
||||
\ '0',
|
||||
\ '1',
|
||||
\ '2147483646',
|
||||
\ '2147483647',
|
||||
\ '2147483647'], getline(1, '$'))
|
||||
bwipe!
|
||||
|
||||
if has('num64')
|
||||
new
|
||||
a
|
||||
-9223372036854775808
|
||||
-9223372036854775807
|
||||
|
||||
-1
|
||||
0
|
||||
1
|
||||
-9223372036854775806
|
||||
9223372036854775806
|
||||
9223372036854775807
|
||||
9223372036854775807
|
||||
-9223372036854775808
|
||||
abc
|
||||
|
||||
.
|
||||
sort n
|
||||
call assert_equal(['',
|
||||
\ 'abc',
|
||||
\ '',
|
||||
\ '-9223372036854775808',
|
||||
\ '-9223372036854775808',
|
||||
\ '-9223372036854775807',
|
||||
\ '-9223372036854775806',
|
||||
\ '-1',
|
||||
\ '0',
|
||||
\ '1',
|
||||
\ '9223372036854775806',
|
||||
\ '9223372036854775807',
|
||||
\ '9223372036854775807'], getline(1, '$'))
|
||||
bwipe!
|
||||
endif
|
||||
endfunc
|
||||
|
||||
|
||||
func Test_sort_cmd_report()
|
||||
enew!
|
||||
call append(0, repeat([1], 3) + repeat([2], 3) + repeat([3], 3))
|
||||
|
||||
Reference in New Issue
Block a user