diff options
Diffstat (limited to 't/rotors.t')
-rw-r--r-- | t/rotors.t | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -3,6 +3,7 @@ use DAKKAR::p 'test'; use List::Util 'shuffle'; use Enigmatic::Rotor; +use Enigmatic::RotorBox; sub test_the_rotor { my ($r,$out,$name) = @_; @@ -56,4 +57,29 @@ subtest 'constraints' => sub { } }; +subtest 'rotor box' => sub { + my %rotors = ( + I => 'EKMFLGDQVZNTOWYHXUSPAIBRCJ', + II => 'AJDKSIRUXBLHWTMCQGZNPYFVOE', + III => 'BDFHJLCPRTXVZNYEIWGAKMUSQO', + IV => 'ESOVPZJAYQUIRHXLNFTGKDCMWB', + V => 'VZBRGITYUPSDNHLXAWMJQOFECK', + VI => 'JPGVOUMFYQBENHZRDKASXLICTW', + VII => 'NZJHGRCXMYSWBOUFAIVLPEKQDT', + VIII => 'FKQHTLXOCBJSPDZRAMEWNIUYGV', + Beta => 'LEYJVCNIXWPBQMDRTAKZGFUHOS', + Gamma => 'FSOKANUERHMBTIYCWLQPZXVGJD', + ); + + my $box = Enigmatic::RotorBox->new(); + + %rotors->each(sub { + my ($rotor,$wiring) = @_; + my $r = $box->get($rotor); + my $out = $wiring->split(qr//); + test_the_rotor($r,$out, + "rotor $rotor from box"); + }); +}; + done_testing(); |