diff options
author | dakkar <dakkar@thenautilus.net> | 2011-08-29 13:54:58 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2011-08-29 13:54:58 +0100 |
commit | 1776bd778db4f6ed72eed47602877ab7a8fb904f (patch) | |
tree | e04b0500dbe53aed33be95d311f46e8e40775017 /t/rotors.t | |
parent | rotor boxes (diff) | |
download | Enigmatic-1776bd778db4f6ed72eed47602877ab7a8fb904f.tar.gz Enigmatic-1776bd778db4f6ed72eed47602877ab7a8fb904f.tar.bz2 Enigmatic-1776bd778db4f6ed72eed47602877ab7a8fb904f.zip |
reflectors, in box, and some refactor
Diffstat (limited to 't/rotors.t')
-rw-r--r-- | t/rotors.t | 26 |
1 files changed, 7 insertions, 19 deletions
@@ -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"); }); }; |