aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-01-06 12:07:20 -0600
committerRob Landley <rob@landley.net>2015-01-06 12:07:20 -0600
commitcc39d95a344240bec8f0c74a02c74d54620b735d (patch)
tree3698fdd43caf67cac4eb3e1a13cd8b6a3474a5b2 /tests
parenta8df744605cb95dfb4bdd45ff64f7932166cc907 (diff)
downloadtoybox-cc39d95a344240bec8f0c74a02c74d54620b735d.tar.gz
More printf cleanup, and test suite entries.
Fixes bug introduced last time where toys.optargs was both snapshotted and used directly and the two fell out of sync.
Diffstat (limited to 'tests')
-rw-r--r--tests/printf.test22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/printf.test b/tests/printf.test
index 96789bd0..ebf536ff 100644
--- a/tests/printf.test
+++ b/tests/printf.test
@@ -6,12 +6,24 @@
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
-#set -x
-testing "printf TEXT" "printf toyTestText" "toyTestText" "" ""
-testing "printf MULTILINE_TEXT" \
- "printf 'Testing\nmultiline\ntext\nfrom\ntoybox\tcommand.\b'" \
- "Testing\nmultiline\ntext\nfrom\ntoybox\tcommand.\b" "" ""
+testing "" "printf TEXT" "TEXT" "" ""
+testing "printf escapes" "printf 'one\ntwo\n\v\t\r\f\e\b\athree'" \
+ "one\ntwo\n\v\t\r\f\e\b\athree" "" ""
+testing "printf %b escapes" "printf %b 'one\ntwo\n\v\t\r\f\e\b\athree'" \
+ "one\ntwo\n\v\t\r\f\e\b\athree" "" ""
+testing "printf null" "printf 'x\0y' | od -An -tx1" ' 78 00 79\n' "" ""
+testing "printf trailing slash" "printf 'abc\'" 'abc\' "" ""
+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 '%x\\n' 0x2a" "2a\n" "" ""
+
+testing "" "printf %d 42" "42" "" ""
+testing "" "printf %d 0x2a" "42" "" ""
+testing "" "printf %d 052" "42" "" ""
+
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" "" ""