From a091f743f9620c41f59891b6594a7122de435f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 7 Mar 2022 23:03:18 +0100 Subject: Complete coverage in base64 tests. --- tests/test/base64.scm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests/test/base64.scm') diff --git a/tests/test/base64.scm b/tests/test/base64.scm index 3463432e..64abd2c3 100644 --- a/tests/test/base64.scm +++ b/tests/test/base64.scm @@ -5,9 +5,11 @@ (define-module (test base64) :use-module (srfi srfi-64) + :use-module (srfi srfi-64 test-error) :use-module (srfi srfi-88) - :use-module ((base64) :select (base64encode base64decode))) + :use-module (base64)) +;; Tests borrowed directly from RFC4648 (test-equal "" (base64encode "")) (test-equal "Zg==" (base64encode "f")) (test-equal "Zm8=" (base64encode "fo")) @@ -22,3 +24,20 @@ (test-equal "foob" (base64decode "Zm9vYg==")) (test-equal "fooba" (base64decode "Zm9vYmE=")) (test-equal "foobar" (base64decode "Zm9vYmFy")) + + +;; Other tests + +;; TODO normalize base64 errors + +(test-error "Invalid base64" + 'misc-error + (base64decode "@@@@")) + +(test-error "To short base64" + 'out-of-range + (base64decode "=")) + +(test-equal "AAECAw==" (bytevector->base64-string #vu8(0 1 2 3))) + +(test-equal #vu8(0 1 2 3) (base64-string->bytevector "AAECAw==")) -- cgit v1.2.3