aboutsummaryrefslogtreecommitdiff
path: root/tests/printf.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
committerRob Landley <rob@landley.net>2014-09-20 13:09:14 -0500
commit387edf547eb09b27ca6d49772eb048d729f09cf4 (patch)
tree59d482f33735690cab6d90723393afa1e2c8dce5 /tests/printf.test
parentd3df423a6cde0c6282658ff628574771d3824d71 (diff)
downloadtoybox-387edf547eb09b27ca6d49772eb048d729f09cf4.tar.gz
Move testsuite out of scripts/test into its own top level tests directory, and make ctrl-c kill "make test" more reliably.
Diffstat (limited to 'tests/printf.test')
-rw-r--r--tests/printf.test29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/printf.test b/tests/printf.test
new file mode 100644
index 00000000..96789bd0
--- /dev/null
+++ b/tests/printf.test
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
+# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
+
+[ -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 '%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" "" ""
+testing "printf '%d %d' 78 79" "printf '%d %d' 78 79" "78 79" "" ""
+testing "printf '%f %f' 78 79" "printf '%f %f' 78 79" \
+ "78.000000 79.000000" "" ""
+testing "printf 'f f' 78 79" "printf 'f f' 78 79" "f f" "" ""
+testing "printf '%i %i' 78 79" "printf '%i %i' 78 79" "78 79" "" ""
+testing "printf '%o %o' 78 79" "printf '%o %o' 78 79" "116 117" "" ""
+testing "printf '%u %u' 78 79" "printf '%u %u' 78 79" "78 79" "" ""
+testing "printf '%u %u' -1 -2" "printf '%u %u' -1 -2" \
+ "18446744073709551615 18446744073709551614" "" ""
+testing "printf '%x %X' 78 79" "printf '%x %X' 78 79" "4e 4F" "" ""
+testing "printf '%g %G' 78 79" "printf '%g %G' 78 79" "78 79" "" ""
+testing "printf '%s %s' 78 79" "printf '%s %s' 78 79" "78 79" "" ""