# HG changeset patch # User Brian Neal # Date 1338010716 18000 # Node ID 345154208fb6d53b903ac364f411f0892a9b5d46 # Parent 81665fcaa36d640d72592417394298179aec9990 The wiring test now tests all ring settings, rotations, and positions. diff -r 81665fcaa36d -r 345154208fb6 enigma/tests/test_rotor.py --- a/enigma/tests/test_rotor.py Sat May 26 00:09:17 2012 -0500 +++ b/enigma/tests/test_rotor.py Sat May 26 00:38:36 2012 -0500 @@ -66,19 +66,21 @@ self.assertEqual(s, rotor.get_display()) def test_wiring(self): - rotor = Rotor('I', WIRING, ring_setting=0, alpha_labels=True) - for n, d in enumerate(ALPHA_LABELS): - rotor.set_display(d) + for r in range(26): + rotor = Rotor('I', WIRING, ring_setting=r, alpha_labels=True) - wiring = collections.deque(WIRING) - wiring.rotate(-n) + for n, d in enumerate(ALPHA_LABELS): + rotor.set_display(d) - for i in range(26): - output = rotor.signal_in(i) + wiring = collections.deque(WIRING) + wiring.rotate(r - n) - expected = (ord(wiring[i]) - ord('A') - n) % 26 - self.assertEqual(output, expected) + for i in range(26): + output = rotor.signal_in(i) - output = rotor.signal_out(expected) - self.assertEqual(output, i) + expected = (ord(wiring[i]) - ord('A') + r - n) % 26 + self.assertEqual(output, expected) + + output = rotor.signal_out(expected) + self.assertEqual(output, i)