diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-08-16 21:58:41 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-08-16 21:58:41 +0200 |
commit | 91984b9034d3b698459622be277d963e0c6df60e (patch) | |
tree | 329479725a833a6bc5ae7b42cf7c1686c6542597 /src/testdir/test_expr.vim | |
parent | e5a8f35b4286135f3469f3b00a6c2220553d9658 (diff) |
patch 7.4.2221v7.4.2221
Problem: printf() does not support binary format.
Solution: Add %b and %B. (Ozaki Kiichi)
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r-- | src/testdir/test_expr.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index e835854031..a7ad65eef4 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -163,6 +163,23 @@ function Test_printf_spec_s() call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) endfunc +function Test_printf_spec_b() + call assert_equal("0", printf('%b', 0)) + call assert_equal("00001100", printf('%08b', 12)) + call assert_equal("11111111", printf('%08b', 0xff)) + call assert_equal(" 1111011", printf('%10b', 123)) + call assert_equal("0001111011", printf('%010b', 123)) + call assert_equal(" 0b1111011", printf('%#10b', 123)) + call assert_equal("0B01111011", printf('%#010B', 123)) + call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890)) + if has('num64') + call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) + call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) + else + call assert_equal("11111111111111111111111111111111", printf('%b', -1)) + endif +endfunc + func Test_substitute_expr() let g:val = 'XXX' call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', '')) |