diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2012-06-01 23:08:32 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2012-06-01 23:30:16 +0200 |
| commit | e3deeebb27c106223fac85848b9bc75bced956eb (patch) | |
| tree | 7cf7c45e71f55f3b0edb4241f1f2c3f656498108 /tests/utils.scm | |
| parent | 69f90f5c81419b55a4de0fd8324356f9116d9f74 (diff) | |
Add (guix utils), with `bytevector->base32-string'.
* guix/utils.scm, tests/utils.scm: New files.
Diffstat (limited to 'tests/utils.scm')
| -rw-r--r-- | tests/utils.scm | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/utils.scm b/tests/utils.scm new file mode 100644 index 00000000000..57705e6f485 --- /dev/null +++ b/tests/utils.scm | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | ;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*- | ||
| 2 | ;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | |||
| 20 | (define-module (test-utils) | ||
| 21 | #:use-module (guix utils) | ||
| 22 | #:use-module (srfi srfi-1) | ||
| 23 | #:use-module (srfi srfi-26) | ||
| 24 | #:use-module (srfi srfi-64) | ||
| 25 | #:use-module (rnrs bytevectors)) | ||
| 26 | |||
| 27 | (test-begin "utils") | ||
| 28 | |||
| 29 | (test-assert "bytevector->base32-string" | ||
| 30 | (fold (lambda (bv expected result) | ||
| 31 | (and result | ||
| 32 | (string=? (bytevector->base32-string bv) | ||
| 33 | expected))) | ||
| 34 | #t | ||
| 35 | |||
| 36 | ;; Examples from RFC 4648. | ||
| 37 | (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar")) | ||
| 38 | '("" | ||
| 39 | "my" | ||
| 40 | "mzxq" | ||
| 41 | "mzxw6" | ||
| 42 | "mzxw6yq" | ||
| 43 | "mzxw6ytb" | ||
| 44 | "mzxw6ytboi"))) | ||
| 45 | |||
| 46 | (test-end) | ||
| 47 | |||
| 48 | |||
| 49 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) | ||
| 50 | |||
| 51 | ;;; Local Variables: | ||
| 52 | ;;; eval: (put 'test-assert 'scheme-indent-function 1) | ||
| 53 | ;;; End: | ||
