From 1c1cd84f9ab59809ad3e8e8ed12c8832ff6a33fa Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 11 May 2010 16:31:02 +0200 Subject: Add tests for short options --- test/50-efa.t | 65 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/test/50-efa.t b/test/50-efa.t index 79ed907..418e17e 100644 --- a/test/50-efa.t +++ b/test/50-efa.t @@ -2,7 +2,7 @@ use strict; use warnings; use 5.010; -use Test::Command tests => 30; +use Test::Command tests => 48; my $efa = 'bin/efa'; my $testarg = "E HBf MH HBf"; @@ -38,45 +38,54 @@ $cmd->exit_isnt_num(0); $cmd->stdout_is_eq(''); $cmd->stderr_like($re_usage); -$cmd = Test::Command->new(cmd => "$efa --exclude invalid $testarg"); +for my $opt (qw/-e --exclude/) { + $cmd = Test::Command->new(cmd => "$efa $opt invalid $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_exclude); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_exclude); +} -$cmd = Test::Command->new(cmd => "$efa --prefer invalid $testarg"); +for my $opt (qw/-P --prefer/) { + $cmd = Test::Command->new(cmd => "$efa $opt invalid $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_prefer); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_prefer); +} -$cmd = Test::Command->new(cmd => "$efa --include invalid $testarg"); +for my $opt (qw/-i --include/) { + $cmd = Test::Command->new(cmd => "$efa $opt invalid $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_include); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_include); +} -$cmd = Test::Command->new(cmd => "$efa --walk-speed invalid $testarg"); +for my $opt (qw/-w --walk-speed/) { + $cmd = Test::Command->new(cmd => "$efa $opt invalid $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_walk_speed); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_walk_speed); +} -# (primitive) argument checking for --time -$cmd = Test::Command->new(cmd => "$efa --time 35:12 $testarg"); +for my $opt (qw/-t --time/) { + $cmd = Test::Command->new(cmd => "$efa $opt 35:12 $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_time); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_time); +} -# (primitive) argument checking for --date -$cmd = Test::Command->new(cmd => "$efa --date 11.23.2010 $testarg"); +for my $opt (qw/-d --date/) { + $cmd = Test::Command->new(cmd => "$efa $opt 11.23.2010 $testarg"); -$cmd->exit_isnt_num(0); -$cmd->stdout_is_eq(''); -$cmd->stderr_is_eq($err_date); + $cmd->exit_isnt_num(0); + $cmd->stdout_is_eq(''); + $cmd->stderr_is_eq($err_date); +} -# --version $cmd = Test::Command->new(cmd => "$efa --version"); $cmd->exit_is_num(0); -- cgit v1.2.3