aboutsummaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-03-07 23:03:18 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-03-07 23:03:18 +0100
commita091f743f9620c41f59891b6594a7122de435f98 (patch)
tree519417fa8df2058083da5234f5daff9d8a16f1dc /tests/test
parentReplace Guile's srfi-64:s test-error with working version. (diff)
downloadcalp-a091f743f9620c41f59891b6594a7122de435f98.tar.gz
calp-a091f743f9620c41f59891b6594a7122de435f98.tar.xz
Complete coverage in base64 tests.
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/base64.scm21
1 files changed, 20 insertions, 1 deletions
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=="))