aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIlya Kuzmich <ilya.kuzmich@gmail.com>2017-05-29 07:05:16 +0300
committerRob Landley <rob@landley.net>2017-07-02 20:28:47 -0500
commit24dfc146470aa8098c49f37a6f10a0687aa66c72 (patch)
tree6e412a33e84a08f395335a609cbfd808e7262943 /tests
parentb8e0920c180f81f86f0888804445f67a2a76fe2b (diff)
downloadtoybox-24dfc146470aa8098c49f37a6f10a0687aa66c72.tar.gz
strings tests and bugfixes
Fixes missing newline in output if last byte of the input is string. Fixes one-off offset bug. Adds strings tests. Signed-off-by: Ilya Kuzmich <ilya.kuzmich@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/strings.test20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/strings.test b/tests/strings.test
new file mode 100644
index 00000000..8becc2f5
--- /dev/null
+++ b/tests/strings.test
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+testing "stdin" "strings" "foobar\n" "" "foobar\n"
+testing "file" "strings input" "foobar\n" "foobar\n" ""
+testing "string to the end" "strings input" "foobar\n" "foobar" ""
+testing "short strings" "strings input" "" "foo\nbar\n" ""
+testing "-n6" "strings -n6 input" "foobar\n" "foobar\nbaz\n" ""
+testing "string and nulls" "strings input" "foobar\nbazfoo\n" \
+ "\0foobar\0\0bazfoo\0foo" ""
+testing "-f" "strings -f input" "input: foobar\n" "foobar\n" ""
+testing "-o" "strings -o input | sed 's/^ *//'" "6 foobar\n" \
+ "\0\0\0\0\0\0foobar\n" ""
+testing "-o, multiple strings" "strings -n3 -o input | sed 's/^ *//'" \
+ "1 foo\n7 bar\n" "\0foo\0b\0bar\n" ""
+testing "-fo" "strings -fo input | sed 's/: */: /'" "input: 6 foobar\n" \
+ "\0\0\0\0\0\0foobar\n" ""