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.9 2003/04/15 16:15:21 kevin Exp $
11 ;;;; *************************************************************************
15 (defpackage #:base64-test
16 (:use #:cl #:kmrcl #:base64 #:util.test))
18 (in-package #:base64-test)
21 (setq *break-on-test-failures* t)
22 (with-tests (:name "cl-base64 tests")
23 (do* ((length 0 (+ 3 length))
24 (string (make-string length) (make-string length))
25 (usb8 (make-usb8-array length) (make-usb8-array length))
26 (integer (random (expt 10 length)) (random (expt 10 length))))
30 (let ((code (random 256)))
31 (setf (schar string i) (code-char code))
32 (setf (aref usb8 i) code)))
34 (do* ((columns 0 (+ columns 4)))
36 ;; Test against cl-base64 routines
37 (test integer (base64-string-to-integer
38 (integer-to-base64-string integer :columns columns))
40 (test string (base64-string-to-string
41 (string-to-base64-string string :columns columns))
44 ;; Test against AllegroCL built-in routines
47 (test integer (excl:base64-string-to-integer
48 (integer-to-base64-string integer :columns columns)))
49 (test integer (base64-string-to-integer
50 (excl:integer-to-base64-string integer)))
51 (test (string-to-base64-string string :columns columns)
52 (excl:usb8-array-to-base64-string usb8
57 (test string (base64-string-to-string
58 (excl:usb8-array-to-base64-string
67 (defun time-routines ()
68 (let* ((str "abcdefghijklmnopqwertyu1234589jhwf2ff")
69 (usb8 (string-to-usb8-array str))
70 (int 12345678901234567890)
72 (time-iterations n (integer-to-base64-string int))
74 (time-iterations n (excl:integer-to-base64-string int))
75 (time-iterations n (string-to-base64-string str))
77 (time-iterations n (excl:usb8-array-to-base64-string usb8))))