📄 caesartest.java
字号:
import junit.framework.TestCase;
/**
* Class for testing Caesar class
*/
public class CaesarTest extends TestCase {
private Cipher cipher = new Caesar();
/**
* Testing the encryption function
*/
public void testEncrypt() {
String plaintext = "geronimo";
String ciphertext = "igtqpkoq";
int key = 2;
cipher.setIntKey(key);
assertEquals(ciphertext, cipher.encrypt(plaintext));
}
/**
* Testing the decryption function
*/
public void testDecrypt() {
String plaintext = "springbreak";
String ciphertext = "hegxcvqgtpz";
int key = 15;
cipher.setIntKey(key);
assertEquals(plaintext, cipher.decrypt(ciphertext));
}
/**
* Verifying encryption
*/
public void testEncryptDecrypt() {
String plaintext = "karelj";
int key = 12;
cipher.setIntKey(key);
assertEquals(plaintext, cipher.decrypt(cipher.encrypt(plaintext)));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -