changeset 2:81665fcaa36d

The Rotor wiring test works through a full rotation.
author Brian Neal <bgneal@gmail.com>
date Sat, 26 May 2012 00:09:17 -0500
parents 9a403915a740
children 345154208fb6
files enigma/tests/test_rotor.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/enigma/tests/test_rotor.py	Fri May 25 23:42:45 2012 -0500
+++ b/enigma/tests/test_rotor.py	Sat May 26 00:09:17 2012 -0500
@@ -4,6 +4,7 @@
 # Py-Enigma is released under the MIT License (see License.txt).
 
 import unittest
+import collections
 import string
 
 from rotors.rotor import Rotor, RotorError, ALPHA_LABELS, NUMERIC_LABELS
@@ -66,14 +67,18 @@
 
     def test_wiring(self):
         rotor = Rotor('I', WIRING, ring_setting=0, alpha_labels=True)
-        rotor.set_display('A')
 
-        for i, s in enumerate(ALPHA_LABELS):
-            pos = ord(s) - ord('A')
-            output = rotor.signal_in(pos)
+        for n, d in enumerate(ALPHA_LABELS):
+            rotor.set_display(d)
 
-            expected = ord(WIRING[i]) - ord('A')
-            self.assertEqual(output, expected)
+            wiring = collections.deque(WIRING)
+            wiring.rotate(-n)
 
-            output = rotor.signal_out(expected)
-            self.assertEqual(output, i)
+            for i in range(26):
+                output = rotor.signal_in(i)
+
+                expected = (ord(wiring[i]) - ord('A') - n) % 26
+                self.assertEqual(output, expected)
+
+                output = rotor.signal_out(expected)
+                self.assertEqual(output, i)