summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2020-11-27 19:28:50 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2021-06-19 15:44:24 +0200
commit7c81a49d762e67b21c99a95b86d1e7886d91de02 (patch)
tree41134870f6edc1b7b5567638f3740758ba5d0fe4 /tests
parent9012da74345b0eea06ab36c93f2f36d5584a014c (diff)
Add a base64 encoder and decoder
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am11
-rw-r--r--tests/base64-error.scm22
-rw-r--r--tests/base64-ok.scm17
3 files changed, 49 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1e4b2df..12699f9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,7 @@
-TESTS = %reldir%/load-library.scm
+TESTS = \
+ %reldir%/load-library.scm \
+ %reldir%/base64-ok.scm \
+ %reldir%/base64-error.scm
EXTRA_DIST += $(TESTS)
@@ -7,3 +10,9 @@ TEST_EXTENSIONS = .scm
AM_TESTS_ENVIRONMENT = $(top_builddir)/pre-inst-env
SCM_LOG_COMPILER = $(GUILE)
AM_SCM_LOG_FLAGS = --no-auto-compile -s
+
+clean-local: %canon_reldir%-clean-local
+
+%canon_reldir%-clean-local:
+ rm -rf %reldir%/*.cache
+ rm -rf %reldir%/*.home
diff --git a/tests/base64-error.scm b/tests/base64-error.scm
new file mode 100644
index 0000000..096e1e8
--- /dev/null
+++ b/tests/base64-error.scm
@@ -0,0 +1,22 @@
+(use-modules
+ (webid-oidc testing)
+ ((webid-oidc stubs) #:prefix stubs:)
+ (webid-oidc errors)
+ (rnrs bytevectors))
+
+(with-test-environment
+ "base64-error"
+ (lambda ()
+ (let ((test "hello :)"))
+ (unless
+ (with-exception-handler
+ (lambda (error)
+ (unless ((record-predicate &not-base64) error)
+ (exit 1))
+ #t)
+ (lambda ()
+ (stubs:base64-decode test)
+ #f)
+ #:unwind? #t
+ #:unwind-for-type &not-base64)
+ (exit 2)))))
diff --git a/tests/base64-ok.scm b/tests/base64-ok.scm
new file mode 100644
index 0000000..724f2db
--- /dev/null
+++ b/tests/base64-ok.scm
@@ -0,0 +1,17 @@
+(use-modules
+ (webid-oidc testing)
+ ((webid-oidc stubs) #:prefix stubs:)
+ (rnrs bytevectors))
+
+(with-test-environment
+ "base64-ok"
+ (lambda ()
+ (let ((test "hello :)"))
+ (let ((encoded (stubs:base64-encode test)))
+ (unless (string? encoded)
+ (exit 1))
+ (let ((decoded (stubs:base64-decode encoded)))
+ (unless (bytevector? decoded)
+ (exit 2))
+ (unless (equal? test (utf8->string decoded))
+ (exit 3)))))))