Add unit tests for SimpleSubCipher (#3688)

This commit is contained in:
Alexandre Velloso
2022-11-06 10:21:22 +00:00
committed by GitHub
parent 1c7da7af25
commit cc17d60d5c
2 changed files with 48 additions and 19 deletions

View File

@ -0,0 +1,37 @@
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);
}
}