Add cipher class, cipher tests, enhance docs in 'AtbashCipher.java' (#5690)

This commit is contained in:
Varnan Rathod
2024-10-11 11:35:26 +05:30
committed by GitHub
parent 2040df88d9
commit 2338428578
3 changed files with 101 additions and 0 deletions

View 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());
}
}