aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.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-base64)
  #:use-module (guix base64)
  #:use-module (rnrs bytevectors)
  #:use-module (srfi srfi-64))

(define (string->base64 str)
  (base64-encode (string->utf8 str)))

;;; Test vectors from <https://tools.ietf.org/rfc/rfc4648.txt>.

(test-begin "base64")

(test-equal "empty string"
  (string->base64 "")
  "")

(test-equal "f"
  (string->base64 "f")
  "Zg==")

(test-equal "fo"
  (string->base64 "fo")
  "Zm8=")

(test-equal "foo"
  (string->base64 "foo")
  "Zm9v")

(test-equal "foob"
  (string->base64 "foob")
  "Zm9vYg==")

(test-equal "fooba"
  (string->base64 "fooba")
  "Zm9vYmE=")

(test-equal "foobar"
  (string->base64 "foobar")
  "Zm9vYmFy")

(test-end "base64")
d>logplainabout -rw-r--r--boot-parameters.scm11862logplainabout -rw-r--r--bournish.scm1919logplainabout -rw-r--r--build-utils.scm8910logplainabout -rw-r--r--builders.scm2902logplainabout -rw-r--r--cache.scm2999logplainabout -rw-r--r--challenge.scm10708logplainabout -rw-r--r--channels.scm28916logplainabout -rw-r--r--civodul.key88561logplainabout -rw-r--r--combinators.scm3045logplainabout -rw-r--r--containers.scm11158logplainabout -rw-r--r--cpan.scm3659logplainabout -rw-r--r--cpio.scm3154logplainabout -rw-r--r--cran.scm4994logplainabout -rw-r--r--crate.scm22188logplainabout -rw-r--r--cve-sample.json46447logplainabout -rw-r--r--cve.scm3672logplainabout -rw-r--r--debug-link.scm6709logplainabout -rw-r--r--derivations.scm62695logplainabout -rw-r--r--discovery.scm2540logplainabout -rw-r--r--dsa.key1432logplainabout -rw-r--r--ed25519.key417logplainabout -rw-r--r--ed25519.sec467logplainabout -rw-r--r--ed25519bis.key409logplainabout -rw-r--r--ed25519bis.sec459logplainabout -rw-r--r--egg.scm4426logplainabout -rw-r--r--elpa.scm2848logplainabout -rw-r--r--file-systems.scm4717logplainabout -rw-r--r--gem.scm6455logplainabout -rw-r--r--gexp.scm73669logplainabout -rw-r--r--git-authenticate.scm15597logplainabout -rw-r--r--git.scm7748logplainabout -rw-r--r--glob.scm2551logplainabout -rw-r--r--gnu-maintenance.scm2449logplainabout -rw-r--r--go.scm20078logplainabout -rw-r--r--grafts.scm25794logplainabout -rw-r--r--graph.scm23089logplainabout -rw-r--r--gremlin.scm3478logplainabout -rw-r--r--guix-archive.sh2803logplainabout -rw-r--r--guix-authenticate.sh3045logplainabout -rw-r--r--guix-build-branch.sh2222logplainabout -rw-r--r--guix-build.sh12426logplainabout -rw-r--r--guix-daemon.sh8308logplainabout -rw-r--r--guix-describe.sh1405logplainabout -rw-r--r--guix-download.sh1485logplainabout -rw-r--r--guix-environment-container.sh6944logplainabout -rw-r--r--guix-environment.sh9270logplainabout -rw-r--r--guix-gc.sh2682logplainabout -rw-r--r--guix-git-authenticate.sh2154logplainabout -rw-r--r--guix-graph.sh2918logplainabout -rw-r--r--guix-hash.sh2631logplainabout -rw-r--r--guix-home.sh3987logplainabout -rw-r--r--guix-lint.sh3213logplainabout -rw-r--r--guix-pack-localstatedir.sh2565logplainabout -rw-r--r--guix-pack-relocatable.sh9237logplainabout -rw-r--r--guix-pack.sh5061logplainabout -rw-r--r--guix-package-aliases.sh2155logplainabout -rw-r--r--guix-package-net.sh7624logplainabout -rw-r--r--guix-package.sh16490logplainabout -rw-r--r--guix-repl.sh2376logplainabout -rw-r--r--guix-shell.sh3651logplainabout -rw-r--r--guix-system.sh10602logplainabout -rw-r--r--hackage.scm11666logplainabout -rw-r--r--home-import.scm5792logplainabout -rw-r--r--import-git.scm10047logplainabout -rw-r--r--import-utils.scm8902logplainabout -rw-r--r--inferior.scm13057logplainabout -rw-r--r--ipfs.scm2021logplainabout -rw-r--r--lint.scm55807logplainabout -rw-r--r--minetest.scm19429logplainabout -rw-r--r--modules.scm2582logplainabout -rw-r--r--monads.scm9099logplainabout -rw-r--r--nar.scm22058logplainabout -rw-r--r--networking.scm4024logplainabout -rw-r--r--offload.scm2683logplainabout -rw-r--r--opam.scm7512logplainabout -rw-r--r--openpgp.scm10284logplainabout -rw-r--r--pack.scm17228logplainabout -rw-r--r--packages.scm80767logplainabout -rw-r--r--pki.scm5220logplainabout -rw-r--r--print.scm5859logplainabout -rw-r--r--processes.scm4691logplainabout -rw-r--r--profiles.scm34985logplainabout -rw-r--r--publish.scm30741logplainabout -rw-r--r--pypi.scm17703logplainabout -rw-r--r--records.scm16887logplainabout -rw-r--r--rsa.key953logplainabout -rw-r--r--scripts.scm2034logplainabout -rw-r--r--search-paths.scm1768logplainabout -rw-r--r--services.scm11536logplainabout d---------services167logplain -rw-r--r--sets.scm1507logplainabout -rw-r--r--signing-key.pub302logplainabout -rw-r--r--signing-key.sec983logplainabout -rw-r--r--size.scm4576logplainabout -rw-r--r--status.scm12235logplainabout -rw-r--r--store-database.scm5421logplainabout -rw-r--r--store-deduplication.scm5266logplainabout -rw-r--r--store-roots.scm1899logplainabout -rw-r--r--store.scm65463logplainabout -rw-r--r--substitute.scm24753logplainabout -rw-r--r--swh.scm4936logplainabout -rw-r--r--syscalls.scm22514logplainabout -rw-r--r--system.scm5151logplainabout -rw-r--r--test.drv5922logplainabout -rw-r--r--texlive.scm4428logplainabout -rw-r--r--transformations.scm21896logplainabout -rw-r--r--ui.scm8936logplainabout -rw-r--r--union.scm9714logplainabout -rw-r--r--upstream.scm1963logplainabout -rw-r--r--utils.scm12288logplainabout -rw-r--r--uuid.scm2755logplainabout -rw-r--r--workers.scm2172logplainabout