comparison enigma/tests/test_plugboard.t.h @ 13:b9d124a15926

To improve cache performance, the enigma machine rotors are now stored together with the reflector in a vector.
author Brian Neal <bgneal@gmail.com>
date Mon, 02 Jul 2012 19:14:36 -0500
parents 232dbe7a3fe0
children
comparison
equal deleted inserted replaced
12:424111a36ed7 13:b9d124a15926
141 } 141 }
142 142
143 void test_get_wiring() 143 void test_get_wiring()
144 { 144 {
145 plugboard pb; 145 plugboard pb;
146 alpha_int_array w(pb.get_wiring()); 146 auto w(pb.get_wiring());
147 147
148 for (int i = 0; i < 26; ++i) 148 for (int i = 0; i < 26; ++i)
149 { 149 {
150 TS_ASSERT_EQUALS(w[i], i); 150 TS_ASSERT_EQUALS(w[i], i);
151 } 151 }
159 } 159 }
160 std::swap(w[0], w[1]); 160 std::swap(w[0], w[1]);
161 std::swap(w[8], w[20]); 161 std::swap(w[8], w[20]);
162 std::swap(w[24], w[25]); 162 std::swap(w[24], w[25]);
163 163
164 alpha_int_array w1(pb.get_wiring()); 164 auto w1(pb.get_wiring());
165 for (int i = 0; i < 26; ++i) 165 for (int i = 0; i < 26; ++i)
166 { 166 {
167 TS_ASSERT_EQUALS(w[i], w1[i]); 167 TS_ASSERT_EQUALS(w[i], w1[i]);
168 } 168 }
169 } 169 }
180 std::swap(w[24], w[25]); 180 std::swap(w[24], w[25]);
181 181
182 plugboard pb; 182 plugboard pb;
183 pb.set_wiring(w); 183 pb.set_wiring(w);
184 184
185 alpha_int_array w2 = pb.get_wiring(); 185 auto w2 = pb.get_wiring();
186 TS_ASSERT_EQUALS(w, w2); 186 TS_ASSERT_EQUALS(w, w2);
187 } 187 }
188 188
189 void test_is_wired() 189 void test_is_wired()
190 { 190 {