summaryrefslogtreecommitdiff
path: root/t/rotors.t
diff options
context:
space:
mode:
Diffstat (limited to 't/rotors.t')
-rw-r--r--t/rotors.t26
1 files changed, 7 insertions, 19 deletions
diff --git a/t/rotors.t b/t/rotors.t
index fb53fe4..90ce6ce 100644
--- a/t/rotors.t
+++ b/t/rotors.t
@@ -1,35 +1,22 @@
#!perl
use DAKKAR::p 'test';
use List::Util 'shuffle';
+use Test::Enigmatic;
use Enigmatic::Rotor;
use Enigmatic::RotorBox;
-sub test_the_rotor {
- my ($r,$out,$name) = @_;
-
- my @in = 'A'..'Z';
- my %map;@map{@in}=@$out;
-
- for my $c ('A' .. 'Z') {
- is($r->map($c),
- $map{$c},
- "$name on $c");
- }
-}
-
subtest 'identity rotor' => sub {
my @in = 'A'..'Z';
my $r = Enigmatic::Rotor->new(@in->join);
- test_the_rotor($r,\@in,'identity');
+ Test::Enigmatic::test_static_map($r,\@in,'identity');
};
-
subtest 'scramble rotor' => sub {
my @out = shuffle 'A'..'Z';
my $r = Enigmatic::Rotor->new(@out->join);
- test_the_rotor($r,\@out,'shuffle');
+ Test::Enigmatic::test_static_map($r,\@out,'shuffle');
};
subtest 'identity rotor, non-default ring setting' => sub {
@@ -39,7 +26,7 @@ subtest 'identity rotor, non-default ring setting' => sub {
wiring => ['A'..'Z']->join,
ring_setting => 1,
);
- test_the_rotor($r,\@out,'ring=1');
+ Test::Enigmatic::test_static_map($r,\@out,'ring=1');
};
subtest 'constraints' => sub {
@@ -77,8 +64,9 @@ subtest 'rotor box' => sub {
my ($rotor,$wiring) = @_;
my $r = $box->get($rotor);
my $out = $wiring->split(qr//);
- test_the_rotor($r,$out,
- "rotor $rotor from box");
+ Test::Enigmatic::test_static_map(
+ $r,$out,
+ "rotor $rotor from box");
});
};