mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Add unit tests for SimpleSubCipher (#3688)
This commit is contained in:

committed by
GitHub

parent
1c7da7af25
commit
cc17d60d5c
@ -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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user