OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD
[android-x86/external-toybox.git] / tests / head.test
1 #!/bin/bash
2
3 [ -f testing.sh ] && . testing.sh
4
5 #testing "name" "command" "result" "infile" "stdin"
6
7 testing "head, stdin" "head -n 1 && echo yes" "one\nyes\n" "" "one\ntwo"
8 testing "head, stdin via -" "head -n 1 - && echo yes" "one\nyes\n" "" "one\ntwo"
9 testing "head, file" "head input -n 1 && echo yes" "one\nyes\n" "one\ntwo" ""
10 testing "head -number" "head -2 input && echo yes" "one\ntwo\nyes\n" \
11         "one\ntwo\nthree\nfour" ""
12 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"
13
14 echo "foo
15 bar
16 baz" > file1
17 testing "head, multiple files" "head -n 2 input file1" "==> input <==\none\ntwo\n\n==> file1 <==\nfoo\nbar\n" "one\ntwo\nthree\n" ""
18 rm file1
19