summaryrefslogtreecommitdiff
path: root/t/stepping.t
diff options
context:
space:
mode:
Diffstat (limited to 't/stepping.t')
-rw-r--r--t/stepping.t31
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();