From 9148240481fd0c13bed3473748a416e21d6c1a70 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 9 Nov 2024 10:17:15 -0500 Subject: Rewrite base64 module and add an encoder. --- tests/base64.scm | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/base64.scm b/tests/base64.scm index dba4f3b..c6ebe8f 100644 --- a/tests/base64.scm +++ b/tests/base64.scm @@ -21,12 +21,28 @@ (with-tests "base64" (test-group "base64-decode" - (test-equal "encoded text no padding" + (test-equal "empty string" + "" + (utf8->string (base64-decode ""))) + (test-equal "no padding" "hello!" (utf8->string (base64-decode "aGVsbG8h"))) - (test-equal "encoded text with one byte of padding" + (test-equal "one byte of padding" "hello" (utf8->string (base64-decode "aGVsbG8="))) - (test-equal "encoded text with two bytes of padding" + (test-equal "two bytes of padding" "what's up?" - (utf8->string (base64-decode "d2hhdCdzIHVwPw=="))))) + (utf8->string (base64-decode "d2hhdCdzIHVwPw==")))) + (test-group "base64-encode" + (test-equal "empty string" + "" + (base64-encode (string->utf8 ""))) + (test-equal "no padding" + "aGVsbG8h" + (base64-encode (string->utf8 "hello!"))) + (test-equal "one byte of padding" + "aGVsbG8=" + (base64-encode (string->utf8 "hello"))) + (test-equal "two bytes of padding" + "d2hhdCdzIHVwPw==" + (base64-encode (string->utf8 "what's up?"))))) -- cgit v1.2.3