diff tests/printf.test @ 1649:66bb2847993d draft

More half-finished cleanup of printf.c, and more test suite entries.
author Rob Landley <rob@landley.net>
date Sat, 10 Jan 2015 20:02:21 -0600
parents d27136a0811b
children 114fb916e04e
line wrap: on
line diff
--- a/tests/printf.test	Tue Jan 06 15:06:51 2015 -0600
+++ b/tests/printf.test	Sat Jan 10 20:02:21 2015 -0600
@@ -21,7 +21,7 @@
 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 @@
   "$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" "" ""