head: add test case for negative -n invocation

Commit 2da9724b56 broke 'head -n -1' and was
later reverted with 0d598ab9f0.

This commit adds a test case to avoid future breakage.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Thomas De Schampheleire 2018-09-13 15:01:45 +02:00 committed by Denys Vlasenko
parent 426aff88a0
commit e0f617699f

31
testsuite/head.tests Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# Copyright 2018 Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
. ./testing.sh
# testing "test name" "command" "expected result" "file input" "stdin"
cat <<EOF > head.input
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11
line 12
EOF
testing "head -n <negative number>" \
"head -n -9 head.input" \
"line 1\nline 2\nline 3\n" \
"" ""
rm head.input
exit $FAILCOUNT