From 70cbfe8eda34df26cc91c51cd77098612e33fd80 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 10 Jan 2015 20:02:21 -0600 Subject: More half-finished cleanup of printf.c, and more test suite entries. --- tests/printf.test | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/printf.test') diff --git a/tests/printf.test b/tests/printf.test index ded169e4..7b4b821d 100644 --- a/tests/printf.test +++ b/tests/printf.test @@ -21,7 +21,7 @@ testing "printf octal" "$PRINTF ' \1\002\429\045x'" ' \001\002"9%x' "" "" testing "printf not octal" "$PRINTF '\9'" '\9' "" "" testing "printf hex" "$PRINTF 'A\x1b\x2B\x3Q\xa' | od -An -tx1" \ ' 41 1b 2b 03 51 0a\n' "" "" -testing "printf " "$PRINTF '%x\n' 0x2a" "2a\n" "" "" +testing "printf %x" "$PRINTF '%x\n' 0x2a" "2a\n" "" "" testing "printf %d 42" "$PRINTF %d 42" "42" "" "" testing "printf %d 0x2a" "$PRINTF %d 0x2a" "42" "" "" @@ -31,6 +31,14 @@ testing "printf %s width precision" \ "$PRINTF '%3s,%.3s,%10s,%10.3s' abcde fghij klmno pqrst" \ "abcde,fgh, klmno, pqr" "" "" +# posix: "The format operand shall be reused as often as necessary to satisfy +# the argument operands." + +testing "printf extra args" "$PRINTF 'abc%s!%ddef\n' X 42 ARG 36" \ + "abcX!42def\nabcARG!36def\n" "" "" + +testing "printf '%3c'" "printf '%3c' x" " x" "" "" + testing "printf '%5d%4d' 1 21 321 4321 54321" \ "$PRINTF '%5d%4d' 1 21 321 4321 54321" " 1 21 321432154321 0" "" "" testing "printf '%c %c' 78 79" "$PRINTF '%c %c' 78 79" "7 7" "" "" -- cgit v1.2.3