mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 06:55:02 +08:00
38 lines
991 B
Java
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);
|
|
}
|
|
|
|
}
|