From c8369caccef256f9e7bfa02ac2cc7fcbd72db04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 9 Jun 2012 15:25:51 +0200 Subject: Add `base32-string->bytevector' and `nix-base32-string->bytevector'. * guix/utils.scm (bytevector-quintet-set!, bytevector-quintet-set-right!, base32-string-unfold, base32-string-unfold-right, make-base32-string->bytevector, base32-string->bytevector, nix-base32-string->bytevector): New procedures. * tests/utils.scm ("base32-string->bytevector", "nix-base32-string->bytevector"): New tests. --- tests/utils.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/utils.scm b/tests/utils.scm index eade84b5d4..edea11db72 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -46,6 +46,22 @@ "mzxw6ytb" "mzxw6ytboi"))) +(test-assert "base32-string->bytevector" + (every (lambda (bv) + (equal? (base32-string->bytevector + (bytevector->base32-string bv)) + bv)) + ;; Examples from RFC 4648. + (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar")))) + +(test-assert "nix-base32-string->bytevector" + (every (lambda (bv) + (equal? (nix-base32-string->bytevector + (bytevector->nix-base32-string bv)) + bv)) + ;; Examples from RFC 4648. + (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar")))) + ;; The following tests requires `nix-hash' in $PATH. (test-skip (if (false-if-exception (system* "nix-hash" "--version")) 0 -- cgit v1.2.3