diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-07-07 12:35:43 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-07-07 12:35:43 +0200 |
commit | d2b2f157a2851da8b4b5119e5b6e3a02494eaede (patch) | |
tree | 6931bec6772fadf7ba45c1263a0a496574b42fc3 | |
parent | d9c788b8031df0b3fbf87a31b1db330a67e3a664 (diff) |
Re-add VRR.pm setup error tests
-rw-r--r-- | Build.PL | 3 | ||||
-rw-r--r-- | t/20-vrr.t | 105 |
2 files changed, 49 insertions, 59 deletions
@@ -7,8 +7,9 @@ use Module::Build; Module::Build->new( build_requires => { - 'Test::More' => 0, 'Test::Compile' => 0, + 'Test::Fatal' => 0, + 'Test::More' => 0, 'Test::Pod' => 0, }, module_name => 'Travel::Routing::DE::VRR', @@ -3,7 +3,8 @@ use strict; use warnings; use 5.010; -use Test::More tests => 59; +use Test::More tests => 67; +use Test::Fatal; BEGIN { use_ok('Travel::Routing::DE::VRR'); @@ -58,23 +59,13 @@ sub is_efa_post { } sub is_efa_err { - my ($key, $val, $str) = @_; - return; # FIXME error handling - my $efa = efa_new([$key, $val]); + my ($ck, $cv, $exception) = @_; - my $val_want = $val; - - if (ref $val eq 'ARRAY') { - $val_want = join(q{ }, @{$val}); - } - - is_deeply( - $efa->{'config'}, efa_conf([$key, $val]), - "conf ok: $key => $val", + isa_ok( + exception { Travel::Routing::DE::VRR->new(%{efa_conf([$ck, $cv])}) }, + $exception, + "$ck => $cv" ); - - # FIXME actual error tests - } is_efa_post('ignored', 'ignored'); @@ -109,16 +100,6 @@ is_efa_post( ['itdTimeMinute', '38'], ); -is_efa_err( - 'departure_time', '37:00', - 'Must match HH:MM', -); - -is_efa_err( - 'departure_time', '07', - 'Must match HH:MM', -); - is_efa_post( 'date', '2.10.2009', ['itdDateDay', '2'], @@ -133,16 +114,6 @@ is_efa_post( ['itdDateYear', (localtime(time))[5] + 1900], ); -is_efa_err( - 'date', '42.5.2003', - 'Invalid day', -); - -is_efa_err( - 'date', '7.', - 'Invalid month', -); - is_efa_post( 'exclude', [qw[zug]], ['inclMOT_0', undef], @@ -155,13 +126,6 @@ is_efa_post( ['inclMOT_10', undef], ); -is_efa_err( - 'exclude', [qw[sonstige invalid]], - 'Must consist of ' - . 'zug s-bahn u-bahn stadtbahn tram stadtbus regionalbus ' - . 'schnellbus seilbahn schiff ast sonstige', -); - is_efa_post( 'select_interchange_by', 'speed', ['routeType', 'LEASTTIME'], @@ -177,11 +141,6 @@ is_efa_post( ['routeType', 'LEASTWALKING'], ); -is_efa_err( - 'select_interchange_by', 'invalid', - 'Must be either speed, nowait or nowalk', -); - is_efa_post( 'train_type', 'local', ['lineRestriction', 403], @@ -197,21 +156,11 @@ is_efa_post( ['lineRestriction', 400], ); -is_efa_err( - 'train_type', 'invalid', - 'Must be one of local/ic/ice', -); - is_efa_post( 'walk_speed', 'normal', ['changeSpeed', 'normal'], ); -is_efa_err( - 'walk_speed', 'invalid', - 'Must be normal, fast or slow', -); - is_efa_post( 'max_interchanges', 5, ['maxChanges', 5], @@ -226,3 +175,43 @@ is_efa_post( 'with_bike', 1, ['bikeTakeAlong', 1], ); + +is_efa_err( + 'departure_time', '37:00', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'departure_time', '07', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'train_type', 'invalid', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'walk_speed', 'invalid', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'select_interchange_by', 'invalid', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'exclude', [qw[sonstige invalid]], + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'date', '42.5.2003', + 'Travel::Routing::DE::VRR::Exception::Setup', +); + +is_efa_err( + 'date', '7.', + 'Travel::Routing::DE::VRR::Exception::Setup', +); |