Added first tests #191
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 9s

This commit is contained in:
2025-12-10 23:20:25 +01:00
parent cc76227199
commit fa2adb8003
74 changed files with 303 additions and 3334 deletions

View File

@@ -0,0 +1,27 @@
from cpl.core.utils.base64 import Base64
def test_encode():
assert Base64.encode("hello world") == "aGVsbG8gd29ybGQ="
s = "foobar"
assert Base64.encode(s) and isinstance(Base64.encode(s), str)
def test_decode():
out = Base64.decode("aGVsbG8gd29ybGQ=")
if isinstance(out, bytes):
out = out.decode("utf-8")
assert out == "hello world"
orig = "äöü߀"
enc = Base64.encode(orig)
dec = Base64.decode(enc)
if isinstance(dec, bytes):
dec = dec.decode("utf-8")
assert dec == orig
def test_is_b64():
assert Base64.is_b64("Zm9vYmFy") # "foobar"
assert Base64.is_b64("Zm8=") # "fo"
assert not Base64.is_b64("not_base64??")