Rob Landley | 2c48247 | 2012-03-12 00:25:40 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | [ -f testing.sh ] && . testing.sh |
| 4 | |
| 5 | #testing "name" "command" "result" "infile" "stdin" |
| 6 | |
| 7 | BIGTEST="one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" |
| 8 | echo -ne "$BIGTEST" > file1 |
| 9 | testing "tail" "tail && echo yes" "oneyes\n" "" "one" |
| 10 | testing "tail file" "tail file1" \ |
| 11 | "two\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" "" |
| 12 | testing "tail -n in bounds" "tail -n 3 file1" "nine\nten\neleven\n" "" "" |
| 13 | testing "tail -n out of bounds" "tail -n 999 file1" "$BIGTEST" "" "" |
| 14 | testing "tail -n+ in bounds" "tail -n +3 file1" \ |
| 15 | "three\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" "" |
| 16 | testing "tail -n+ outof bounds" "tail -n +999 file1" "" "" "" |
| 17 | testing "tail -c in bounds" "tail -c 27 file1" \ |
| 18 | "even\neight\nnine\nten\neleven\n" "" "" |
| 19 | testing "tail -c out of bounds" "tail -c 999 file1" "$BIGTEST" "" "" |
| 20 | testing "tail -c+ in bounds" "tail -c +27 file1" \ |
| 21 | "x\nseven\neight\nnine\nten\neleven\n" "" "" |
| 22 | testing "tail -c+ out of bonds" "tail -c +999 file1" "" "" "" |
| 23 | rm file1 |
| 24 | |
| 25 | optional TAIL_SEEK |
| 26 | testing "tail noseek -n in bounds" "tail -n 3" "nine\nten\neleven\n" \ |
| 27 | "" "$BIGTEST" |
| 28 | testing "tail noseek -n out of bounds" "tail -n 999" "$BIGTEST" "" "$BIGTEST" |
| 29 | testing "tail noseek -n+ in bounds" "tail -n +3" \ |
| 30 | "three\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\n" "" \ |
| 31 | "$BIGTEST" |
| 32 | testing "tail noseek -n+ outof bounds" "tail -n +999" "" "" "$BIGTEST" |
| 33 | testing "tail noseek -c in bounds" "tail -c 27" \ |
| 34 | "even\neight\nnine\nten\neleven\n" "" "$BIGTEST" |
| 35 | testing "tail noseek -c out of bounds" "tail -c 999" "$BIGTEST" "" "$BIGTEST" |
| 36 | testing "tail noseek -c+ in bounds" "tail -c +27" \ |
| 37 | "x\nseven\neight\nnine\nten\neleven\n" "" "$BIGTEST" |
| 38 | testing "tail noseek -c+ out of bonds" "tail -c +999" "" "" "$BIGTEST" |