aboutsummaryrefslogtreecommitdiff
path: root/challenge-074/lance-wicks/perl/t/FNR.t
blob: 8bb52b5133a36e57af20c27740f58ab5c0ae5a5d (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
use Test2::V0 -target => 'FNR';

subtest 'from_string()' => sub {
    subtest 'Example 1' => sub {
        note "Input: ‘ababc’";
        note "Output: ‘abb#c’";
        is $CLASS->from_string('ababc'), 'abb#c',
            'The first example is correct';
    };

    subtest 'Example 2' => sub {
        note "Input: ‘xyzzyx’";
        note "Output: ‘xyzyx#’";

        is $CLASS->from_string('xyzzyx'), 'xyzyx#',
            'The second example is correct';

    };
};

subtest '_fnr()' => sub {
    my %tests = (
        'a'     => 'a',
        'ab'    => 'b',
        'aba'   => 'b',
        'abab'  => '#',
        'ababc' => 'c'
    );

    while ( my ( $input, $expected ) = each %tests ) {
        is $CLASS->_fnr($input), $expected, "$input should return $expected";
    }
};

done_testing;