Files
Java/src/test/java/com/thealgorithms/ciphers/SimpleSubCipherTest.java
2022-11-06 10:21:22 +00:00

38 lines
991 B
Java

package com.thealgorithms.ciphers;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
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);
}
}