summaryrefslogtreecommitdiff
path: root/t/21-iris-stations.t
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2015-09-12 14:03:09 +0200
committerDaniel Friesel <derf@finalrewind.org>2015-09-12 14:03:09 +0200
commit3cccdc35bc5b4edcc97d486cf9ed50fc7b2ca82a (patch)
treedead79a7978971ebe80c84b75d2d4559360d5e14 /t/21-iris-stations.t
parent4caa67e1f2ca8ec055acf24f04d99da028e5c06f (diff)
use Text::Levenshtein(XS) for fuzzy station name matching
Diffstat (limited to 't/21-iris-stations.t')
-rw-r--r--t/21-iris-stations.t34
1 files changed, 19 insertions, 15 deletions
diff --git a/t/21-iris-stations.t b/t/21-iris-stations.t
index 55938c4..c440fd0 100644
--- a/t/21-iris-stations.t
+++ b/t/21-iris-stations.t
@@ -10,16 +10,10 @@ BEGIN {
}
require_ok('Travel::Status::DE::IRIS::Stations');
-my @emptypairs = grep { not (length($_->[0]) and length($_->[1])) }
- Travel::Status::DE::IRIS::Stations::get_stations;
+my @emptypairs = grep { not( length( $_->[0] ) and length( $_->[1] ) ) }
+ Travel::Status::DE::IRIS::Stations::get_stations;
-is_deeply(\@emptypairs, [], 'no stations with empty code / name');
-
-is_deeply(
- [],
- [ Travel::Status::DE::IRIS::Stations::get_station('doesnotexist') ],
- 'get_station: returns empty list for no match'
-);
+is_deeply( \@emptypairs, [], 'no stations with empty code / name' );
is_deeply(
[ [ 'EE', 'Essen Hbf' ] ],
@@ -52,13 +46,23 @@ is_deeply(
);
is_deeply(
- [ [ 'EG', 'Gelsenk Hbf' ], [ 'EGZO', 'Gelsenk Zoo' ] ],
- [ Travel::Status::DE::IRIS::Stations::get_station('Gelsenk') ],
- 'get_station: partial match by name works'
+ [ [ 'KM', 'M\'gladbach Hbf' ] ],
+ [ Travel::Status::DE::IRIS::Stations::get_station('mgladbach hbf') ],
+ 'get_station: close fuzzy match works (one result)'
+);
+
+is_deeply(
+ [ [ 'KM', 'M\'gladbach Hbf' ] ],
+ [ Travel::Status::DE::IRIS::Stations::get_station('Mgladbach Bbf') ],
+ 'get_station: close fuzzy match is case insensitive'
);
is_deeply(
- [ [ 'EG', 'Gelsenk Hbf' ], [ 'EGZO', 'Gelsenk Zoo' ] ],
- [ Travel::Status::DE::IRIS::Stations::get_station('gelsenk') ],
- 'get_station: partial match by name is case insensitive'
+ [
+ [ 'NKL', 'Kirchenlaibach' ],
+ [ 'KM', 'M\'gladbach Hbf' ],
+ [ 'XSRC', 'Reichenbach Kt' ]
+ ],
+ [ Travel::Status::DE::IRIS::Stations::get_station('Moenchengladbach Hbf') ],
+ 'get_station: partial match works (several results for very fuzzy match)'
);