summaryrefslogtreecommitdiff
path: root/t/21-get-stop-by-name.t
blob: 43952ac9a1394573dd1bf21d9475183e5aaf028e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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');