diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-15 16:08:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-15 16:08:56 +0100 |
commit | 21e551cce26ea6ff389b6c90f1945facf1a8a066 (patch) | |
tree | 80588221ad797d6d72ef2dfe9826dcee8d0fcd52 | |
parent | a9659e0da41388f2c7aedccf016c2fe2eeec6a82 (diff) | |
download | vim-git-21e551cce26ea6ff389b6c90f1945facf1a8a066.tar.gz |
patch 8.1.0596: not all parts of printf() are testedv8.1.0596
Problem: Not all parts of printf() are tested.
Solution: Add a few more test cases. (Dominique Pelle, closes #3691)
-rw-r--r-- | src/testdir/test_expr.vim | 31 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index c14b6e671..216a00f7d 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -142,6 +142,22 @@ function Test_printf_misc() call assert_equal('173', printf('%O', 123)) call assert_equal('7b', printf('%x', 123)) call assert_equal('7B', printf('%X', 123)) + + call assert_equal('123', printf('%hd', 123)) + call assert_equal('-123', printf('%hd', -123)) + call assert_equal('-1', printf('%hd', 0xFFFF)) + call assert_equal('-1', printf('%hd', 0x1FFFFF)) + + call assert_equal('123', printf('%hu', 123)) + call assert_equal('65413', printf('%hu', -123)) + call assert_equal('65535', printf('%hu', 0xFFFF)) + call assert_equal('65535', printf('%hu', 0x1FFFFF)) + + call assert_equal('123', printf('%ld', 123)) + call assert_equal('-123', printf('%ld', -123)) + call assert_equal('65535', printf('%ld', 0xFFFF)) + call assert_equal('131071', printf('%ld', 0x1FFFF)) + if has('ebcdic') call assert_equal('#', printf('%c', 123)) else @@ -185,6 +201,11 @@ function Test_printf_misc() call assert_equal(' 123', printf('% *d', 5, 123)) call assert_equal(' +123', printf('%+ *d', 5, 123)) + call assert_equal('foobar', printf('%.*s', 9, 'foobar')) + call assert_equal('foo', printf('%.*s', 3, 'foobar')) + call assert_equal('', printf('%.*s', 0, 'foobar')) + call assert_equal('foobar', printf('%.*s', -1, 'foobar')) + " Simple quote (thousand grouping char) is ignored. call assert_equal('+00123456', printf("%+'09d", 123456)) @@ -207,6 +228,11 @@ function Test_printf_misc() call assert_equal(' 00123', printf('%6.5d', 123)) call assert_equal(' 0007b', printf('%6.5x', 123)) + call assert_equal('123', printf('%.2d', 123)) + call assert_equal('0123', printf('%.4d', 123)) + call assert_equal('0000000123', printf('%.10d', 123)) + call assert_equal('123', printf('%.0d', 123)) + call assert_equal('abc', printf('%2s', 'abc')) call assert_equal('abc', printf('%2S', 'abc')) call assert_equal('abc', printf('%.4s', 'abc')) @@ -305,6 +331,11 @@ function Test_printf_float() call assert_equal('inf', printf('%s', 1.0/0.0)) call assert_equal('-inf', printf('%s', -1.0/0.0)) + " Test special case where max precision is truncated at 340. + call assert_equal('1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.330f', 1.0)) + call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.340f', 1.0)) + call assert_equal('1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', printf('%.350f', 1.0)) + " Float nan (not a number) has no sign. call assert_equal('nan', printf('%f', sqrt(-1.0))) call assert_equal('nan', printf('%f', 0.0/0.0)) diff --git a/src/version.c b/src/version.c index 83026baee..577be31d9 100644 --- a/src/version.c +++ b/src/version.c @@ -800,6 +800,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 596, +/**/ 595, /**/ 594, |