mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.0.0167: str2nr()/str2float() fail with negative values
Problem: str2nr() and str2float() do not always work with negative values. Solution: Be more flexible about handling signs. (LemonBoy, closes #1332) Add more tests.
This commit is contained in:
18
src/testdir/test_functions.vim
Normal file
18
src/testdir/test_functions.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
" Tests for various functions.
|
||||
|
||||
func Test_str2nr()
|
||||
call assert_equal(0, str2nr(''))
|
||||
call assert_equal(1, str2nr('1'))
|
||||
call assert_equal(1, str2nr(' 1 '))
|
||||
|
||||
call assert_equal(1, str2nr('+1'))
|
||||
call assert_equal(1, str2nr('+ 1'))
|
||||
call assert_equal(1, str2nr(' + 1 '))
|
||||
|
||||
call assert_equal(-1, str2nr('-1'))
|
||||
call assert_equal(-1, str2nr('- 1'))
|
||||
call assert_equal(-1, str2nr(' - 1 '))
|
||||
|
||||
call assert_equal(123456789, str2nr('123456789'))
|
||||
call assert_equal(-123456789, str2nr('-123456789'))
|
||||
endfunc
|
Reference in New Issue
Block a user