~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/fmt/base.pl

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# Basic tests for "fmt".
 
3
 
 
4
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
 
 
19
use strict;
 
20
 
 
21
(my $program_name = $0) =~ s|.*/||;
 
22
 
 
23
my @Tests =
 
24
    (
 
25
     ['8-bit-pfx', qw (-p 'ç'),
 
26
      {IN=> "ça\nçb\n"},
 
27
      {OUT=>"ça b\n"}],
 
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}],
 
37
     ['obs-1', '-c -72',
 
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}],
 
41
 
 
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"}],
 
46
 
 
47
     # Don't remove prefix from a prefix-only line.
 
48
     ['pfx-only', qw (-p '>'),
 
49
      {IN=>  ">\n"},
 
50
      {OUT=> ">\n"}],
 
51
 
 
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'),
 
56
      {IN=>  "fo\n"},
 
57
      {OUT=> "fo\n"}],
 
58
);
 
59
 
 
60
my $save_temps = $ENV{DEBUG};
 
61
my $verbose = $ENV{VERBOSE};
 
62
my $prog = 'fmt';
 
63
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
 
64
exit $fail;