2
# Basic tests for "fmt".
4
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
(my $program_name = $0) =~ s|.*/||;
25
['8-bit-pfx', qw (-p 'ç'),
28
['wide-1', '-w 32768',
29
{ERR => "fmt: invalid width: '32768'\n"}, {EXIT => 1}],
30
['wide-2', '-w 2147483647',
31
{ERR => "fmt: invalid width: '2147483647'\n"}, {EXIT => 1}],
32
['bad-suffix', '-72x', {IN=> ''},
33
{ERR => "fmt: invalid width: '72x'\n"}, {EXIT => 1}],
34
['no-file', 'no-such-file',
35
{ERR => "fmt: cannot open 'no-such-file' for reading:"
36
. " No such file or directory\n"}, {EXIT => 1}],
38
{ERR => "fmt: invalid option -- 7; -WIDTH is recognized only when it"
39
. " is the first\noption; use -w N instead\n"
40
. "Try 'fmt --help' for more information.\n" }, {EXIT => 1}],
42
# With --prefix=P, do not remove leading space on lines without the prefix.
43
['pfx-1', qw (-p '>'),
44
{IN=> " 1\n 2\n\t3\n\t\t4\n> quoted\n> text\n"},
45
{OUT=> " 1\n 2\n\t3\n\t\t4\n> quoted text\n"}],
47
# Don't remove prefix from a prefix-only line.
48
['pfx-only', qw (-p '>'),
52
# With a multi-byte prefix, say, "foo", don't empty a line that
53
# starts with a strict prefix (e.g. "fo") of that prefix.
54
# With fmt from coreutils-6.7, it would mistakenly output an empty line.
55
['pfx-of-pfx', qw (-p 'foo'),
60
my $save_temps = $ENV{DEBUG};
61
my $verbose = $ENV{VERBOSE};
63
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);