printf.sh (2122B)
- #!/bin/sh
- # SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
- # SPDX-License-Identifier: MPL-2.0
- plans=37
- WD="$(dirname "$0")/../"
- target="${WD}/cmd/printf"
- . "${WD}/test-cmd/tap.sh"
- t esc '\b\t\n' '
- '
- t octal '\041' '!'
- t hex '\x7B\x7d' '{}'
- t_args repeat 'foo,bar,baz,' '%s,' foo bar baz
- var_c_upper='\c@\cA\cB\cC\cD\cE\cF\cG\cH\cI\cJ\cK\cL\cM\cN\cO\cP\cQ\cR\cS\cT\cU\cV\cW\cX\cY\cZ\c[\c\\c]\c^\c_ !"#$\%&'"'"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\c?'
- t_file esc_c_upper "${WD}/test-cmd/inputs/all_ascii" "${var_c_upper}"
- var_c_lower='\c@\ca\cb\cc\cd\ce\cf\cg\ch\ci\cj\ck\cl\cm\cn\co\cp\cq\cr\cs\ct\cu\cv\cw\cx\cy\cz\c[\c\\c]\c^\c_ !"#$\%&'"'"'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\c?'
- t_file esc_c_lower "${WD}/test-cmd/inputs/all_ascii" "${var_c_lower}"
- t_args clear_vs_caret_esc 'foo :bar' 'foo \cH:%brat\n' 'bar\cHbaz'
- t_args fmt_b '
- !{}' '%b' '\b\t\n\041\x7B\x7d'
- t_args fmt_b_rightpad '!{} .' '%-6b%c' '\041\x7B\x7d' .
- t_args fmt_b_leftpad ' !{}.' '%6b%c' '\041\x7B\x7d' .
- t_args fmt_q_print 'foo
- baré
- ' '%q\n' foo baré
- t_args fmt_q_cntrl "back$'\cHdel\c?nl\cJ'" '%q' 'backdelnl
- '
- t_args fmt_q_sq "single$'\\'quote'" %q "single'quote"
- t_args fmt_q_dq "double$'"'"'"quote'" %q 'double"quote'
- t_args fmt_c 'foo' %c f oo oooo
- t_args fmt_d 10, %d, 10
- t_args fmt_Ld 10, %Ld, 10
- t_args fmt_i 10, %i, 10
- t_args fmt_o 12, %o, 10
- t_args fmt_u 10, %u, 10
- t_args fmt_x a, %x, 10
- t_args fmt_X A, %X, 10
- t_args fmt_e '1.000000e+01,' %e, 10
- t_args fmt_E '1.000000E+01,' %E, 10
- t_args fmt_f '10.000000,' %f, 10
- t_args fmt_Lf '10.000000,' %Lf, 10
- t_args fmt_F '10.000000,' %F, 10
- t_args fmt_g '10,' %g, 10
- t_args fmt_G '10,' %G, 10
- t_args fmt_a '0x1.4p+3,' %a, 10
- t_args fmt_A '0X1.4P+3,' %A, 10
- t_args nofmtarg '[
- ]' '[%s\n]'
- t_args nofmtconv 'foobar
- ' 'foobar\n' 1 2 3
- t_args nofmtconv_caret 'foo bar' 'foo \cHbar'
- t_args precision_s 'abcde' '%.5s' abcdefghijklmnopqrstuvwxyz
- t_args nofmt_doubledash '--' '--'
- t_args doubledash_fmt '10.000000' '--' '%f' 10