summaryrefslogtreecommitdiff
path: root/tests/base64.scm
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2024-11-09 10:17:15 -0500
committerDavid Thompson <dthompson2@worcester.edu>2024-11-09 10:17:15 -0500
commit9148240481fd0c13bed3473748a416e21d6c1a70 (patch)
tree143c26925ae2647d3a7b98611c39b0916debab51 /tests/base64.scm
parent31b0a07f6a3ea3c37ae39740948f8d6471d8e5a3 (diff)
Rewrite base64 module and add an encoder.
Diffstat (limited to 'tests/base64.scm')
-rw-r--r--tests/base64.scm24
1 files changed, 20 insertions, 4 deletions
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?")))))