-
Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathADFGVXCipherTest.java
46 lines (35 loc) · 1.22 KB
/
ADFGVXCipherTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.thealgorithms.ciphers;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class ADFGVXCipherTest {
private final ADFGVXCipher adfgvxCipher = new ADFGVXCipher();
@Test
void testEncrypt() {
String message = "attack at 1200am";
String key = "PRIVACY";
String encrypted = adfgvxCipher.encrypt(message, key);
assertEquals("DGDDDAGDDGAFADDFDADVDVFAADVX", encrypted);
}
@Test
void testDecrypt() {
String encrypted = "DGDDDAGDDGAFADDFDADVDVFAADVX";
String key = "PRIVACY";
String decrypted = adfgvxCipher.decrypt(encrypted, key);
assertEquals("ATTACKAT1200AM", decrypted);
}
@Test
void testEmptyInput() {
String encrypted = adfgvxCipher.encrypt("", "PRIVACY");
String decrypted = adfgvxCipher.decrypt("", "PRIVACY");
assertEquals("", encrypted);
assertEquals("", decrypted);
}
@Test
void testShortKey() {
String message = "TESTING";
String key = "A";
String encrypted = adfgvxCipher.encrypt(message, key);
String decrypted = adfgvxCipher.decrypt(encrypted, key);
assertEquals("TESTING", decrypted);
}
}