From 24dedb2618abc80efc2af10de597d1debbeba69f Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 29 Aug 2011 14:49:07 +0100 Subject: crypto train, with some stepping --- t/stepping.t | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 t/stepping.t (limited to 't/stepping.t') 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(); -- cgit v1.2.3