3 #=======================================================================
5 # File ID: 88233274-7669-11e0-919c-574686701d8e
6 # Test suite for roundgpx(1).
9 # ©opyleft 2011– Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 3 or later, see end of
11 # file for legal stuff.
12 #=======================================================================
18 # push(@INC, "$ENV{'HOME'}/bin/STDlibdirDTS");
19 use Test
::More
qw{no_plan
};
28 our $CMD = '../../roundgpx';
42 $progname =~ s/^.*\/(.*?)$/$1/;
43 our $VERSION = '0.00';
45 Getopt
::Long
::Configure
('bundling');
48 'all|a' => \
$Opt{'all'},
49 'debug' => \
$Opt{'debug'},
50 'help|h' => \
$Opt{'help'},
51 'todo|t' => \
$Opt{'todo'},
52 'verbose|v+' => \
$Opt{'verbose'},
53 'version' => \
$Opt{'version'},
55 ) || die("$progname: Option error. Use -h for help.\n");
57 $Opt{'debug'} && ($Debug = 1);
58 $Opt{'help'} && usage
(0);
59 if ($Opt{'version'}) {
64 diag
(sprintf('========== Executing %s v%s ==========',
68 if ($Opt{'todo'} && !$Opt{'all'}) {
74 testcmd("$CMD command", # {{{
87 diag
('Testing -h (--help) option...');
88 likecmd
("$CMD -h", # {{{
89 '/ Show this help\./',
92 'Option -h prints help screen',
96 diag
('Testing -v (--verbose) option...');
97 likecmd
("$CMD -hv", # {{{
98 '/^\n\S+ v\d\.\d\d\n/s',
101 'Option --version with -h returns version number and help screen',
105 diag
('Testing --version option...');
106 likecmd
("$CMD --version", # {{{
107 '/^\S+ v\d\.\d\d\n/',
110 'Option --version returns version number',
115 chomp(my $gpx_header = <<'END');
116 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
119 creator="gpst - http://sunny256.github.com/gpstools/"
120 xmlns="http://www.topografix.com/GPX/1/1"
121 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
122 xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
126 testcmd
("$CMD files/rounding.gpx", # {{{
131 <trkpt lat="51.483816" lon="0.000053">
132 <time>2003-02-11T12:17:05Z</time>
134 <trkpt lat="51.483777" lon="-0.000021">
136 <time>2003-02-11T12:17:15Z</time>
138 <trkpt lat="51.483754" lon="-0.000089">
140 <time>2003-02-11T12:17:21Z</time>
142 <trkpt lat="51.483622" lon="0.000027">
143 <time>2003-02-11T12:27:41Z</time>
151 'Round files/rounding.gpx',
159 if ($Opt{'all'} || $Opt{'todo'}) {
160 diag
('Running TODO tests...'); # {{{
165 # Insert TODO tests here.
171 diag
('Testing finished.');
175 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
177 my $deb_str = $Opt{'debug'} ?
' --debug' : '';
184 my $TMP_STDERR = 'roundgpx-stderr.tmp';
186 if (defined($Exp_stderr) && !length($deb_str)) {
187 $stderr_cmd = " 2>$TMP_STDERR";
189 is
(`$Cmd$deb_str$stderr_cmd`, $Exp_stdout, $Txt);
191 if (defined($Exp_stderr)) {
192 if (!length($deb_str)) {
193 is
(file_data
($TMP_STDERR), $Exp_stderr, "$Txt (stderr)");
197 diag
("Warning: stderr not defined for '$Txt'");
199 is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
206 my ($Cmd, $Exp_stdout, $Exp_stderr, $Exp_retval, $Desc) = @_;
208 my $deb_str = $Opt{'debug'} ?
' --debug' : '';
215 my $TMP_STDERR = 'roundgpx-stderr.tmp';
217 if (defined($Exp_stderr) && !length($deb_str)) {
218 $stderr_cmd = " 2>$TMP_STDERR";
220 like
(`$Cmd$deb_str$stderr_cmd`, "$Exp_stdout", $Txt);
222 if (defined($Exp_stderr)) {
223 if (!length($deb_str)) {
224 like
(file_data
($TMP_STDERR), "$Exp_stderr", "$Txt (stderr)");
228 diag
("Warning: stderr not defined for '$Txt'");
230 is
($ret_val >> 8, $Exp_retval, "$Txt (retval)");
236 # Return file content as a string {{{
239 if (open(my $fp, '<', $File)) {
251 # Print program version {{{
252 print("$progname v$VERSION\n");
258 # Send the help message to stdout {{{
261 if ($Opt{'verbose'}) {
267 Usage: $progname [options] [file [files [...]]]
269 Contains tests for the roundgpx(1) program.
274 Run all tests, also TODOs.
278 Run only the TODO tests.
280 Increase level of verbosity. Can be repeated.
282 Print version information.
284 Print debugging messages.
292 # Print a status message to stderr based on verbosity level {{{
293 my ($verbose_level, $Txt) = @_;
295 if ($Opt{'verbose'} >= $verbose_level) {
296 print(STDERR
"$progname: $Txt\n");
304 # Plain Old Documentation (POD) {{{
314 roundgpx.t [options] [file [files [...]]]
318 Contains tests for the roundgpx(1) program.
324 =item B<-a>, B<--all>
326 Run all tests, also TODOs.
328 =item B<-h>, B<--help>
330 Print a brief help summary.
332 =item B<-t>, B<--todo>
334 Run only the TODO tests.
336 =item B<-v>, B<--verbose>
338 Increase level of verbosity. Can be repeated.
342 Print version information.
346 Print debugging messages.
352 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
356 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
357 This is free software; see the file F<COPYING> for legalese stuff.
361 This program is free software: you can redistribute it and/or modify it
362 under the terms of the GNU General Public License as published by the
363 Free Software Foundation, either version 3 of the License, or (at your
364 option) any later version.
366 This program is distributed in the hope that it will be useful, but
367 WITHOUT ANY WARRANTY; without even the implied warranty of
368 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
369 See the GNU General Public License for more details.
371 You should have received a copy of the GNU General Public License along
373 If not, see L<http://www.gnu.org/licenses/>.
381 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :