summaryrefslogtreecommitdiff
path: root/t/21-get-stop-by-name.t
diff options
context:
space:
mode:
Diffstat (limited to 't/21-get-stop-by-name.t')
-rw-r--r--t/21-get-stop-by-name.t44
1 files changed, 44 insertions, 0 deletions
diff --git a/t/21-get-stop-by-name.t b/t/21-get-stop-by-name.t
new file mode 100644
index 0000000..43952ac
--- /dev/null
+++ b/t/21-get-stop-by-name.t
@@ -0,0 +1,44 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+use utf8;
+
+use Encode qw(decode);
+use File::Slurp qw(slurp);
+use List::Util qw(first);
+use Test::More tests => 5;
+
+BEGIN {
+ use_ok('Travel::Status::DE::ASEAG');
+}
+require_ok('Travel::Status::DE::ASEAG');
+
+my $rawstr = slurp('t/in/aseag_20131223T132300');
+my $s = Travel::Status::DE::ASEAG->new_from_raw(
+ raw_str => $rawstr,
+ hide_past => 0
+);
+
+# fuzzy matching: bushof should return Aachen Bushof, Eschweiler Bushof,
+# Eupon Bushof
+
+my @fuzzy = $s->get_stop_by_name('bushof');
+
+is_deeply(\@fuzzy, ['Aachen Bushof', 'Eschweiler Bushof', 'Eupen Bushof'],
+'fuzzy match for "bushof" works');
+
+# fuzzy matching: whitespaces work
+
+@fuzzy = $s->get_stop_by_name('Aachen Bushof');
+
+is_deeply(\@fuzzy, ['Aachen Bushof'],
+'fuzzy match with exact name "Aachen Bushof" works');
+
+# fuzzy matching: exact name only matches one, even though longer alternatives
+# exist
+
+@fuzzy = $s->get_stop_by_name('brand');
+
+is_deeply(\@fuzzy, ['Brand'],
+'fuzzy match with exact name "brand" works');