| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use Test::Most; |
| 4 |
use Data::Password::zxcvbn::Combinatorics qw(enumerate_substitution_maps); |
| 5 |
|
| 6 |
subtest 'enumerate_substitution_maps' => sub { |
| 7 |
my @cases = ( |
| 8 |
[ {'a' => ['@']} => [{'@' => 'a'}] ], |
| 9 |
|
| 10 |
[ {'a' => ['@', '4']} => [{'@' => 'a'}, {'4' => 'a'}] ], |
| 11 |
|
| 12 |
[ {'a' => ['@', '4'], 'c' => ['(']} => |
| 13 |
[{'(' => 'c', '@' => 'a'}, {'(' => 'c', '4' => 'a'}] ], |
| 14 |
|
| 15 |
[ {'a' => ['@', '4'], 'c' => ['(', '@']} => [ |
| 16 |
{'(' => 'c', '@' => 'a'}, |
| 17 |
{'(' => 'c', '4' => 'a'}, |
| 18 |
{'@' => 'a'}, |
| 19 |
{'@' => 'c'}, |
| 20 |
{'4' => 'a', '@' => 'c'} |
| 21 |
] ], |
| 22 |
); |
| 23 |
for my $case (@cases) { |
| 24 |
my ($table,$expected) = @{$case}; |
| 25 |
my $result = enumerate_substitution_maps($table); |
| 26 |
cmp_deeply( |
| 27 |
$result, |
| 28 |
bag(@{$expected}), |
| 29 |
'should produce the expected value', |
| 30 |
) or explain $result; |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
done_testing; |