Skip to content

Commit 260e3d8

Browse files
authored
feat: add test cases in cipher's autokey (TheAlgorithms#11881)
1 parent 2d671df commit 260e3d8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ciphers/autokey.py

+16
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def encrypt(plaintext: str, key: str) -> str:
2424
Traceback (most recent call last):
2525
...
2626
ValueError: plaintext is empty
27+
>>> encrypt("coffee is good as python", "")
28+
Traceback (most recent call last):
29+
...
30+
ValueError: key is empty
31+
>>> encrypt(527.26, "TheAlgorithms")
32+
Traceback (most recent call last):
33+
...
34+
TypeError: plaintext must be a string
2735
"""
2836
if not isinstance(plaintext, str):
2937
raise TypeError("plaintext must be a string")
@@ -80,6 +88,14 @@ def decrypt(ciphertext: str, key: str) -> str:
8088
Traceback (most recent call last):
8189
...
8290
TypeError: ciphertext must be a string
91+
>>> decrypt("", "TheAlgorithms")
92+
Traceback (most recent call last):
93+
...
94+
ValueError: ciphertext is empty
95+
>>> decrypt("vvjfpk wj ohvp su ddylsv", 2)
96+
Traceback (most recent call last):
97+
...
98+
TypeError: key must be a string
8399
"""
84100
if not isinstance(ciphertext, str):
85101
raise TypeError("ciphertext must be a string")

0 commit comments

Comments
 (0)