summaryrefslogtreecommitdiff
path: root/src/testdir/test_functions.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-10 16:12:29 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-10 16:12:29 +0100
commit08243d26d22ad44a857d02c90071578577b8a55d (patch)
treeaf209d8ff3b3ec6d755acb9a113584d44f50c747 /src/testdir/test_functions.vim
parent03c60c1573cdbebbb662863cfc1780d19d511db5 (diff)
downloadvim-git-08243d26d22ad44a857d02c90071578577b8a55d.tar.gz
patch 8.0.0167: str2nr()/str2float() fail with negative valuesv8.0.0167
Problem: str2nr() and str2float() do not always work with negative values. Solution: Be more flexible about handling signs. (LemonBoy, closes #1332) Add more tests.
Diffstat (limited to 'src/testdir/test_functions.vim')
-rw-r--r--src/testdir/test_functions.vim18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
new file mode 100644
index 000000000..ec816d141
--- /dev/null
+++ b/src/testdir/test_functions.vim
@@ -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