1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: Regression tests for cl-base64
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Jan 2003
10 ;;;; $Id: base64-tests.lisp,v 1.11 2003/04/15 16:22:45 kevin Exp $
11 ;;;; *************************************************************************
15 (defpackage #:base64-test
16 (:use #:cl #:kmrcl #:base64))
18 (in-package #:base64-test)
21 (do* ((length 0 (+ 3 length))
22 (string (make-string length) (make-string length))
23 (usb8 (make-usb8-array length) (make-usb8-array length))
24 (integer (random (expt 10 length)) (random (expt 10 length))))
28 (let ((code (random 256)))
29 (setf (schar string i) (code-char code))
30 (setf (aref usb8 i) code)))
32 (do* ((columns 0 (+ columns 4)))
34 ;; Test against cl-base64 routines
35 (assert (= integer (base64-string-to-integer
36 (integer-to-base64-string integer :columns columns))))
37 (assert (string= (base64-string-to-string
38 (string-to-base64-string string :columns columns))))
40 ;; Test against AllegroCL built-in routines
43 (assert (= integer (excl:base64-string-to-integer
44 (integer-to-base64-string integer :columns columns))))
45 (assert (= integer (base64-string-to-integer
46 (excl:integer-to-base64-string integer))))
47 (assert (string= (string-to-base64-string string :columns columns)
48 (excl:usb8-array-to-base64-string usb8
52 (assert (string= string (base64-string-to-string
53 (excl:usb8-array-to-base64-string
58 (format t "~&All tests passed~%")
62 (defun time-routines ()
63 (let* ((str "abcdefghijklmnopqwertyu1234589jhwf2ff")
64 (usb8 (string-to-usb8-array str))
65 (int 12345678901234567890)
67 (time-iterations n (integer-to-base64-string int))
69 (time-iterations n (excl:integer-to-base64-string int))
70 (time-iterations n (string-to-base64-string str))
72 (time-iterations n (excl:usb8-array-to-base64-string usb8))))