mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-13 07:13:37 +08:00
Add Polybius Cipher (#3185)
This commit is contained in:
45
src/test/java/com/thealgorithms/ciphers/PolybiusTest.java
Normal file
45
src/test/java/com/thealgorithms/ciphers/PolybiusTest.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class PolybiusTest {
|
||||
|
||||
@Test
|
||||
void testEncrypt() {
|
||||
// Given
|
||||
String plaintext = "HELLOWORLD";
|
||||
|
||||
// When
|
||||
String actual = Polybius.encrypt(plaintext);
|
||||
|
||||
// Then
|
||||
assertEquals("12042121244124322103", actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDecrypt() {
|
||||
// Given
|
||||
String ciphertext = "12042121244124322103";
|
||||
|
||||
// When
|
||||
String actual = Polybius.decrypt(ciphertext);
|
||||
|
||||
// Then
|
||||
assertEquals("HELLOWORLD", actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsTextTheSameAfterEncryptionAndDecryption() {
|
||||
// Given
|
||||
String plaintext = "HELLOWORLD";
|
||||
|
||||
// When
|
||||
String encryptedText = Polybius.encrypt(plaintext);
|
||||
String actual = Polybius.decrypt(encryptedText);
|
||||
|
||||
// Then
|
||||
assertEquals(plaintext, actual);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user