diff options
author | Timothy Elliott <tle@holymonkey.com> | 2012-02-10 21:59:57 -0800 |
---|---|---|
committer | Timothy Elliott <tle@holymonkey.com> | 2012-02-10 21:59:57 -0800 |
commit | 270366f582fdf4fc704c4896b15efa0e84eb77a0 (patch) | |
tree | 3e2273054888ecbbd2a24a9001408e1b072a1716 /scripts/test/head.test | |
parent | 365bda87f40d0a2d410ebfe025d43ee13444058f (diff) | |
download | toybox-270366f582fdf4fc704c4896b15efa0e84eb77a0.tar.gz |
Add tests for head
This exposed one issue in head.c -- printf was not flushing and
file names could appear after file contents instead of before.
The issue is fixed by calling xflush after xprintf.
Diffstat (limited to 'scripts/test/head.test')
-rw-r--r-- | scripts/test/head.test | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/test/head.test b/scripts/test/head.test new file mode 100644 index 00000000..eeb07e00 --- /dev/null +++ b/scripts/test/head.test @@ -0,0 +1,17 @@ +#!/bin/bash + +[ -f testing.sh ] && . testing.sh + +#testing "name" "command" "result" "infile" "stdin" + +testing "head, stdin" "head -n 1 && echo yes" "one\nyes\n" "" "one\ntwo" +testing "head, stdin via -" "head -n 1 - && echo yes" "one\nyes\n" "" "one\ntwo" +testing "head, file" "head input -n 1 && echo yes" "one\nyes\n" "one\ntwo" "" +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" + +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" "" +rm file1 + |