mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-26 14:04:17 +08:00
Add cipher class, cipher tests, enhance docs in 'AtbashCipher.java' (#5690)
This commit is contained in:
28
src/test/java/com/thealgorithms/ciphers/AtbashTest.java
Normal file
28
src/test/java/com/thealgorithms/ciphers/AtbashTest.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.thealgorithms.ciphers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class AtbashTest {
|
||||
|
||||
@Test
|
||||
public void atbashEncrypt() {
|
||||
AtbashCipher normalToEncrypt = new AtbashCipher("Hello World! 123, @cipher abcDEF ZYX 987 madam zzZ Palindrome!");
|
||||
String expectedText = "Svool Dliow! 123, @xrksvi zyxWVU ABC 987 nzwzn aaA Kzormwilnv!";
|
||||
|
||||
normalToEncrypt.setString(normalToEncrypt.convert());
|
||||
|
||||
assertEquals(expectedText, normalToEncrypt.getString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atbashDecrypt() {
|
||||
AtbashCipher encryptToNormal = new AtbashCipher("Svool Dliow! 123, @xrksvi zyxWVU ABC 987 nzwzn aaA Kzormwilnv!");
|
||||
String expectedText = "Hello World! 123, @cipher abcDEF ZYX 987 madam zzZ Palindrome!";
|
||||
|
||||
encryptToNormal.setString(encryptToNormal.convert());
|
||||
|
||||
assertEquals(expectedText, encryptToNormal.getString());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user