OSDN Git Service

teach head -v and -q
[android-x86/external-toybox.git] / tests / head.test
index 83d9399..6ed027c 100755 (executable)
@@ -11,9 +11,19 @@ testing "-number" "head -2 input && echo yes" "one\ntwo\nyes\n" \
        "one\ntwo\nthree\nfour" ""
 testing "head, default lines" "head" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" "" "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
 
+# coreutils & busybox name stdin as "standard input", toybox uses "-"
+testing "-v file" "head -v -n 1 input" "==> input <==\none\n" "one\ntwo\n" ""
+testing "-v stdin" "head -v -n 1 | sed 's/==> standard input <==/==> - <==/'" \
+       "==> - <==\none\n" "" "one\ntwo\n"
+
+testing "file and stdin" "head -n 1 input - | sed 's/==> standard input <==/==> - <==/'" \
+       "==> input <==\none\n\n==> - <==\nfoo\n" "one\ntwo\n" "foo\nbar\n"
+
 echo "foo
 bar
 baz" > file1
 testing "head, multiple files" "head -n 2 input file1" "==> input <==\none\ntwo\n\n==> file1 <==\nfoo\nbar\n" "one\ntwo\nthree\n" ""
+testing "-q, multiple files" "head -q -n 2 input file1" "one\ntwo\nfoo\nbar\n" \
+       "one\ntwo\nthree\n" ""
 rm file1