comparison enigma/tests/test_machine.t.h @ 8:b90a41f0cd94

Created enigma_machine::army_str() & navy_str() functions for logging.
author Brian Neal <bgneal@gmail.com>
date Fri, 29 Jun 2012 20:29:41 -0500
parents db1216d380b3
children 280facb82b80
comparison
equal deleted inserted replaced
7:db1216d380b3 8:b90a41f0cd94
28 void test_set_display4() 28 void test_set_display4()
29 { 29 {
30 enigma_machine m({"Gamma", "II", "IV", "V"}, {}, "B-Thin"); 30 enigma_machine m({"Gamma", "II", "IV", "V"}, {}, "B-Thin");
31 TS_ASSERT_THROWS(m.set_display("BCD"), enigma_machine_error); 31 TS_ASSERT_THROWS(m.set_display("BCD"), enigma_machine_error);
32 TS_ASSERT_THROWS_NOTHING(m.set_display("ABCD")); 32 TS_ASSERT_THROWS_NOTHING(m.set_display("ABCD"));
33 }
34
35 void test_navy_str()
36 {
37 const std::string stecker = "1/20 2/12 4/6 7/10 8/13 14/23 15/16 17/25 18/26 22/24";
38 enigma_machine machine({"Beta", "II", "IV", "I"}, {0, 0, 0, 21}, "B-Thin", stecker);
39
40 TS_ASSERT_EQUALS(machine.navy_str(), "B-Thin Beta/0 II/0 IV/0 I/21 AAAA "
41 "1/20 2/12 4/6 7/10 8/13 14/23 15/16 17/25 18/26 22/24");
42 }
43
44 void test_army_str()
45 {
46 enigma_machine machine({"II", "IV", "V"}, {1, 20, 11}, "B",
47 "AV BS CG DL FU HZ IN KM OW RX");
48
49 TS_ASSERT_EQUALS(machine.army_str(), "B II/1 IV/20 V/11 AAA "
50 "AV BS CG DL FU HZ IN KM OW RX");
33 } 51 }
34 }; 52 };
35 53
36 class stepping_test_suite : public CxxTest::TestSuite 54 class stepping_test_suite : public CxxTest::TestSuite
37 { 55 {