forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleSubCipherTest.java
36 lines (26 loc) · 990 Bytes
/
SimpleSubCipherTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.thealgorithms.ciphers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class SimpleSubCipherTest {
SimpleSubCipher simpleSubCipher = new SimpleSubCipher();
@Test
void simpleSubCipherEncryptTest() {
// given
String text = "defend the east wall of the castle";
String cipherSmall = "phqgiumeaylnofdxjkrcvstzwb";
// when
String cipherText = simpleSubCipher.encode(text, cipherSmall);
// then
assertEquals("giuifg cei iprc tpnn du cei qprcni", cipherText);
}
@Test
void simpleSubCipherDecryptTest() {
// given
String encryptedText = "giuifg cei iprc tpnn du cei qprcni";
String cipherSmall = "phqgiumeaylnofdxjkrcvstzwb";
// when
String decryptedText = simpleSubCipher.decode(encryptedText, cipherSmall);
// then
assertEquals("defend the east wall of the castle", decryptedText);
}
}