aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2015, 2020 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-base32)
  #:use-module (gcrypt hash)
  #:use-module (guix base32)
  #:use-module (guix utils)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-64)
  #:use-module (ice-9 match)
  #:use-module (rnrs bytevectors)
  #:use-module (rnrs io ports))

;; Test the (guix base32) module.

(test-begin "base32")

(test-assert "bytevector->base32-string"
  (fold (lambda (bv expected result)
          (and result
               (string=? (bytevector->base32-string bv)
                         expected)))
        #t

        ;; Examples from RFC 4648.
        (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))
        '(""
          "my"
          "mzxq"
          "mzxw6"
          "mzxw6yq"
          "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"))))

(test-equal "&invalid-base32-character"
  #\e
  (guard (c ((invalid-base32-character? c)
             (invalid-base32-character-value c)))
    (nix-base32-string->bytevector
     (string-append (make-string 51 #\a) "e"))))

(test-end)
ent'. Ludovic Courtès 2014-05-11doc: Mention upgrades that trigger a lot of rebuilds....* HACKING (Commit Access): Mention upgrades that trigger a lot rebuilds. Ludovic Courtès 2014-03-10doc: Update packaging guidelines....* HACKING (Submitting Patches): Mention 'git send-mail'. * doc/guix.texi (Packaging Guidelines): More details on how to prepare a package module. (Contributing): Add reference to #guix channel on Freenode. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Pierre-Antoine Rault 2013-12-07doc: Adjust "Building from Git" instructions....* HACKING (Building from Git): As a follow-up to ff1cbb9, update the error reported when pkg.m4 is missing. Suggested by John Darrington <john@darrington.wattle.id.au>. Ludovic Courtès 2013-09-07doc: Add "Data Types and Pattern Matching" to the Coding Style....* HACKING (Data Types and Pattern Matching): New section. Ludovic Courtès 2013-08-30doc: Add note about .dir-locals.el....* HACKING (Coding Style): Mention special indentation rules and .dir-locals.el. Ludovic Courtès 2013-08-30doc: Add a "Coding Style" section in 'HACKING'....* HACKING (Coding Style): New section. Ludovic Courtès 2013-08-30doc: Remove "Adding new packages" from `HACKING'....* HACKING (Adding new packages): Remove since it's now in the manual. Ludovic Courtès 2013-08-26doc: Change `HACKING' to refer to guix-devel@gnu.org....Reported by Alex Sassmannshausen <alex.sassmannshausen@gmail.com>. * HACKING: Replace "bug-guix" by "guix-devel". Ludovic Courtès 2013-07-19doc: Improve build instructions in README and HACKING....* README (Requirements): Remove Nixpkgs. Remove mentions of building from Git. (Installation): Refer to the manual. * HACKING: List requirements for when building from Git. Remove the `dot: Command not found' error. Ludovic Courtès 2013-07-13doc: Add "Building from Git" to 'HACKING'.Nikita Karetnikov 2013-07-07doc: Move the packaging guidelines to the manual....* HACKING (Packaging Guidelines): Remove. * doc/guix.texi (Packaging Guidelines): New node. Ludovic Courtès 2013-07-07doc: Add a "Porting" section....* HACKING (Porting the Guix distro on a new platform): Remove. * doc/guix.texi (Porting): New node. Describe cross-compilation as the only approach. Ludovic Courtès 2013-06-10doc: Mention copyright/license auditing in `HACKING'.Ludovic Courtès 2013-06-09doc: Update bootstrap-related info in `HACKING'.Ludovic Courtès 2013-06-04doc: Write about patch submission and packaging guidelines....* HACKING: Update the command names from `guix-build' to `guix build' & co. (Submitting Patches, Packaging Guidelines): New sections. * doc/guix.texi (Contributing): New section. Ludovic Courtès 2013-02-12doc: Add the commit policy to HACKING....* HACKING (Commit Access): New section. Ludovic Courtès 2013-01-22doc: Add "The Perfect Setup" in 'HACKING'....* HACKING (The Perfect Setup): New section. Ludovic Courtès 2013-01-21Update 'HACKING'....* HACKING (When the platform is supported by Nixpkgs): Update the example. Nikita Karetnikov 2013-01-18Update `HACKING'....* HACKING: Capitalize the title. (Running Guix before it is installed): New section. (Adding new packages): Update example. Ludovic Courtès 2013-01-08doc: Update porting instructions in `HACKING'....* HACKING (When the platform is supported by Nixpkgs): Update instructions. Ludovic Courtès 2012-11-21doc: Document basic package definitions....* doc/guix.texi (Programming Interface): Add introduction. (Defining Packages): Populate. Ludovic Courtès 2012-11-18Turn Guix into "GNU Guix"....* configure.ac: Change package name to "GNU Guix", and bug-report address to `gnu-system-discuss@gnu.org'. * doc/guix.texi: Replace "Guix" by "GNU Guix" in some places. (Top, Introduction): Mention "for the GNU system". * HACKING, README: Use "GNU Guix" instead of "Guix" in some places. Ludovic Courtès 2012-11-04distro: Move bootstrap packages to (distro packages bootstrap)....* distro/packages/base.scm (glibc-dynamic-linker, %bootstrap-guile, bootstrap-origin, package-from-tarball, %bootstrap-base-url, %bootstrap-coreutils&co, %bootstrap-binutils, %bootstrap-glibc, %bootstrap-gcc, %bootstrap-inputs, package-with-bootstrap-guile): Move to ... * distro/packages/bootstrap.scm: ... here. New file. * Makefile.am (MODULES): Add it. * tests/builders.scm: Use (distro packages bootstrap). (%bootstrap-guile): Remove. * tests/packages.scm: Likewise. * tests/union.scm: Likewise, and remove @@ to access %bootstrap-inputs. * tests/derivations.scm: Use (distro packages bootstrap) and remove @@ to access %bootstrap-coreutils&co. * HACKING (When the platform is supported by Nixpkgs): Update accordingly. Ludovic Courtès 2012-11-04doc: Add "Adding new packages" in `HACKING'....* HACKING (Adding new packages): New section. Ludovic Courtès 2012-10-25doc: Add `HACKING'....* HACKING: New file. * Makefile.am (EXTRA_DIST): Add it. Ludovic Courtès