1
1
import org .junit .jupiter .api .BeforeEach ;
2
2
import org .junit .jupiter .api .Disabled ;
3
+ import org .junit .jupiter .api .DisplayName ;
3
4
import org .junit .jupiter .api .Test ;
4
5
5
6
import static org .assertj .core .api .Assertions .assertThat ;
@@ -18,6 +19,7 @@ public void setup() {
18
19
* problem with shift ciphers, some characters will always output the key verbatim.
19
20
*/
20
21
@ Test
22
+ @ DisplayName ("Can encode" )
21
23
public void randomKeyCipherCanEncode () {
22
24
String plainText = "aaaaaaaaaa" ;
23
25
String cipherText = randomKeyCipher .getKey ().substring (0 , 10 );
@@ -26,6 +28,7 @@ public void randomKeyCipherCanEncode() {
26
28
27
29
@ Disabled ("Remove to run test" )
28
30
@ Test
31
+ @ DisplayName ("Can decode" )
29
32
public void randomKeyCipherCanDecode () {
30
33
String cipherText = "aaaaaaaaaa" ;
31
34
assertThat (randomKeyCipher .decode (randomKeyCipher .getKey ().substring (0 , 10 )))
@@ -34,19 +37,23 @@ public void randomKeyCipherCanDecode() {
34
37
35
38
@ Disabled ("Remove to run test" )
36
39
@ Test
40
+ @ DisplayName ("Is reversible. I.e., if you apply decode in a encoded result, \n " +
41
+ "you must see the same plaintext encode parameter as a result of the decode method" )
37
42
public void randomKeyCipherIsReversible () {
38
43
String plainText = "abcdefghij" ;
39
44
assertThat (randomKeyCipher .decode (randomKeyCipher .encode (plainText ))).isEqualTo (plainText );
40
45
}
41
46
42
47
@ Disabled ("Remove to run test" )
43
48
@ Test
49
+ @ DisplayName ("Key is made only of lowercase letters" )
44
50
public void randomKeyCipherKeyIsLowercaseLetters () {
45
51
assertThat (randomKeyCipher .getKey ()).matches ("^[a-z]+$" );
46
52
}
47
53
48
54
@ Disabled ("Remove to run test" )
49
55
@ Test
56
+ @ DisplayName ("Can encode" )
50
57
public void substitutionCipherCanEncode () {
51
58
String plainText = "aaaaaaaaaa" ;
52
59
String cipherText = "abcdefghij" ;
@@ -55,6 +62,7 @@ public void substitutionCipherCanEncode() {
55
62
56
63
@ Disabled ("Remove to run test" )
57
64
@ Test
65
+ @ DisplayName ("Can decode" )
58
66
public void substitutionCipherCanDecode () {
59
67
String plainText = "abcdefghij" ;
60
68
String cipherText = "aaaaaaaaaa" ;
@@ -63,13 +71,16 @@ public void substitutionCipherCanDecode() {
63
71
64
72
@ Disabled ("Remove to run test" )
65
73
@ Test
74
+ @ DisplayName ("Is reversible. I.e., if you apply decode in a encoded result, \n " +
75
+ "you must see the same plaintext encode parameter as a result of the decode method" )
66
76
public void substitutionCipherIsReversibleGivenKey () {
67
77
String plainText = "abcdefghij" ;
68
78
assertThat (substitutionCipher .decode (substitutionCipher .encode (plainText ))).isEqualTo (plainText );
69
79
}
70
80
71
81
@ Disabled ("Remove to run test" )
72
82
@ Test
83
+ @ DisplayName ("Can double shift encode" )
73
84
public void substitutionCipherCanDoubleShiftEncode () {
74
85
String plainText = "iamapandabear" ;
75
86
String cipherText = "qayaeaagaciai" ;
@@ -78,6 +89,7 @@ public void substitutionCipherCanDoubleShiftEncode() {
78
89
79
90
@ Disabled ("Remove to run test" )
80
91
@ Test
92
+ @ DisplayName ("Can wrap on encode" )
81
93
public void substitutionCipherCanWrapEncode () {
82
94
String plainText = "zzzzzzzzzz" ;
83
95
String cipherText = "zabcdefghi" ;
@@ -86,6 +98,7 @@ public void substitutionCipherCanWrapEncode() {
86
98
87
99
@ Disabled ("Remove to run test" )
88
100
@ Test
101
+ @ DisplayName ("Can wrap on decode" )
89
102
public void substitutionCipherCanWrapDecode () {
90
103
String plainText = "zabcdefghi" ;
91
104
String cipherText = "zzzzzzzzzz" ;
@@ -94,6 +107,7 @@ public void substitutionCipherCanWrapDecode() {
94
107
95
108
@ Disabled ("Remove to run test" )
96
109
@ Test
110
+ @ DisplayName ("Can decode messages longer than the key" )
97
111
public void substitutionCipherMessageLongerThanKey () {
98
112
String plainText = "iamapandabear" ;
99
113
String key = "abc" ;
0 commit comments