diff options
author | dakkar <dakkar@thenautilus.net> | 2011-08-29 14:49:07 +0100 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2011-08-29 14:49:07 +0100 |
commit | 24dedb2618abc80efc2af10de597d1debbeba69f (patch) | |
tree | 9a5055ded078239f56046695179dcbe2215706cb /t/stepping.t | |
parent | notches (diff) | |
download | Enigmatic-24dedb2618abc80efc2af10de597d1debbeba69f.tar.gz Enigmatic-24dedb2618abc80efc2af10de597d1debbeba69f.tar.bz2 Enigmatic-24dedb2618abc80efc2af10de597d1debbeba69f.zip |
crypto train, with some stepping
Diffstat (limited to 't/stepping.t')
-rw-r--r-- | t/stepping.t | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/stepping.t b/t/stepping.t new file mode 100644 index 0000000..f50bce9 --- /dev/null +++ b/t/stepping.t @@ -0,0 +1,31 @@ +#!perl +use DAKKAR::p 'test'; + +use Enigmatic::Rotor; +use Enigmatic::Reflector; +use Enigmatic::CryptTrain; + +subtest 'first position' => sub { + my @in = 'A'..'Z'; + + my @rots = map { Enigmatic::Rotor->new(@in->join) } 1..3; + my $refl = Enigmatic::Reflector->new(@in->join); + my $train = Enigmatic::CryptTrain->new({ + rotors => \@rots, + reflector => $refl, + positions => [0,0,0], + }); + + my $pos=0; + for my $c ('A' .. 'Z') { + is($train->map($c), + $c, + "identity train on $c"); + ++$pos;$pos%=26; + is_deeply([$train->positions], + [$pos,0,0], + 'no notches, only 1st moved'); + } +}; + +done_testing(); |