Fix columnarTranspositionCipher and typos in Test (#5649)

This commit is contained in:
SAIVARDHAN15
2024-10-10 01:11:25 +05:30
committed by GitHub
parent 029dd85646
commit 6e6028e3d0
2 changed files with 21 additions and 22 deletions

View File

@ -20,7 +20,7 @@ public class ColumnarTranspositionCipherTest {
@Test
public void testEncryption() {
String encryptedText = ColumnarTranspositionCipher.encrpyter(plaintext, keyword);
String encryptedText = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
assertNotNull(encryptedText, "The encrypted text should not be null.");
assertFalse(encryptedText.isEmpty(), "The encrypted text should not be empty.");
// Check if the encrypted text is different from the plaintext
@ -29,19 +29,19 @@ public class ColumnarTranspositionCipherTest {
@Test
public void testDecryption() {
String encryptedText = ColumnarTranspositionCipher.encrpyter(plaintext, keyword);
String decryptedText = ColumnarTranspositionCipher.decrypter();
String encryptedText = ColumnarTranspositionCipher.encrypt(plaintext, keyword);
String decryptedText = ColumnarTranspositionCipher.decrypt();
assertEquals(plaintext.replaceAll(" ", ""), decryptedText.replaceAll(" ", ""), "The decrypted text should match the original plaintext, ignoring spaces.");
assertEquals(encryptedText, ColumnarTranspositionCipher.encrpyter(plaintext, keyword), "The encrypted text should be the same when encrypted again.");
assertEquals(encryptedText, ColumnarTranspositionCipher.encrypt(plaintext, keyword), "The encrypted text should be the same when encrypted again.");
}
@Test
public void testLongPlainText() {
String longText = "This is a significantly longer piece of text to test the encryption and decryption capabilities of the Columnar Transposition Cipher. It should handle long strings gracefully.";
String encryptedText = ColumnarTranspositionCipher.encrpyter(longText, keyword);
String decryptedText = ColumnarTranspositionCipher.decrypter();
String encryptedText = ColumnarTranspositionCipher.encrypt(longText, keyword);
String decryptedText = ColumnarTranspositionCipher.decrypt();
assertEquals(longText.replaceAll(" ", ""), decryptedText.replaceAll(" ", ""), "The decrypted text should match the original long plaintext, ignoring spaces.");
assertEquals(encryptedText, ColumnarTranspositionCipher.encrpyter(longText, keyword), "The encrypted text should be the same when encrypted again.");
assertEquals(encryptedText, ColumnarTranspositionCipher.encrypt(longText, keyword), "The encrypted text should be the same when encrypted again.");
}
}