Mercurial > vim
diff src/testdir/test_expr.vim @ 9894:b01afb4e8f66 v7.4.2221
commit https://github.com/vim/vim/commit/91984b9034d3b698459622be277d963e0c6df60e
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 16 21:58:41 2016 +0200
patch 7.4.2221
Problem: printf() does not support binary format.
Solution: Add %b and %B. (Ozaki Kiichi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 16 Aug 2016 22:00:06 +0200 |
parents | 41c5d59e7e10 |
children | 885e3c9c0e10 |
line wrap: on
line diff
--- 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', ''))