test-base64.stk 2.44 KB
Newer Older
Erick Gallesio's avatar
Erick Gallesio committed
1 2
;;;;
;;;; test-base64.stk		-- Testing base64 functions
3 4 5 6
;;;;
;;;; Copyright © 2006-2007 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
;;;;
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
7 8 9 10
;;;; This program 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 2 of the License, or
;;;; (at your option) any later version.
11
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
12 13 14 15
;;;; This program 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.
16
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
17 18
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
19
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
Erick Gallesio's avatar
Erick Gallesio committed
20
;;;; USA.
21
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
;;;;           Author: Erick Gallesio [eg@essi.fr]
;;;;    Creation date: 26-Nov-2006 10:47 (eg)
;;;; Last file update: 13-May-2007 23:52 (eg)
;;;;

(require "test")

(test-section "Base64 functions")

;;------------------------------------------------------------------
(test-subsection "Encoding")

(test "encoding length 0" ""          (base64-encode-string ""))
(test "encoding length 1" "YQ=="      (base64-encode-string "a"))
(test "encoding length 2" "YWI="      (base64-encode-string "ab"))
(test "encoding length 3" "YWJj"      (base64-encode-string "abc"))
(test "encoding length 4" "YWJjZA=="  (base64-encode-string "abcd"))
(test "encoding length 62"
      "MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFy\nc3R1dnd4eXo="
      (base64-encode-string
       "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"))


;;------------------------------------------------------------------
(test-subsection "Decoding")

(test "decoding length 0" ""       (base64-decode-string ""))
(test "decoding length 1" "a"      (base64-decode-string "YQ=="))
(test "decoding length 2" "ab"     (base64-decode-string "YWI="))
(test "decoding length 3" "abc"    (base64-decode-string "YWJj"))
(test "decoding length 4" "abcd"   (base64-decode-string "YWJjZA=="))
(test "decoding length 26"
      "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
      (base64-decode-string
       "MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo="))



;;------------------------------------------------------------------
(test-section-end)