feat: add test cases in cipher's autokey (#11881)

This commit is contained in:
Jeel Rupapara 2024-10-08 17:03:28 +05:30 committed by GitHub
parent 2d671df073
commit 260e3d8b35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,14 @@ def encrypt(plaintext: str, key: str) -> str:
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: plaintext is empty ValueError: plaintext is empty
>>> encrypt("coffee is good as python", "")
Traceback (most recent call last):
...
ValueError: key is empty
>>> encrypt(527.26, "TheAlgorithms")
Traceback (most recent call last):
...
TypeError: plaintext must be a string
""" """
if not isinstance(plaintext, str): if not isinstance(plaintext, str):
raise TypeError("plaintext must be a string") raise TypeError("plaintext must be a string")
@ -80,6 +88,14 @@ def decrypt(ciphertext: str, key: str) -> str:
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: ciphertext must be a string TypeError: ciphertext must be a string
>>> decrypt("", "TheAlgorithms")
Traceback (most recent call last):
...
ValueError: ciphertext is empty
>>> decrypt("vvjfpk wj ohvp su ddylsv", 2)
Traceback (most recent call last):
...
TypeError: key must be a string
""" """
if not isinstance(ciphertext, str): if not isinstance(ciphertext, str):
raise TypeError("ciphertext must be a string") raise TypeError("ciphertext must be a string")