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.1 2003/04/15 15:34:43 kevin Exp $
11 ;;;; *************************************************************************
15 (defpackage #:base64-test
16 (:use #:cl #:kmrcl #:base64 #:util.test))
18 (in-package #:base64-test)
21 (with-tests (:name "cl-base64 tests")
22 (do* ((length 0 (+ 3 length))
23 (string (make-string length) (make-string length))
24 (usb8 (make-usb8-array length) (make-usb8-array length))
25 (integer (random (expt 10 length)) (random (expt 10 length))))
29 (let ((code (random 256)))
30 (setf (schar string i) (code-char code))
31 (setf (aref usb8 i) code)))
33 (do* ((columns 0 (+ columns 4)))
35 ;; Test against cl-base64 routines
36 (test integer (base64-string-to-integer
37 (integer-to-base64-string integer :columns columns)))
38 (test string (base64-string-to-string
39 (string-to-base64-string string :columns columns))
42 ;; Test against AllegroCL built-in routines
45 (test integer (excl:base64-string-to-integer
46 (integer-to-base64-string integer :columns columns)))
47 (test integer (base64-string-to-integer
48 (excl:integer-to-base64-string integer)))
49 (test (string-to-base64-string string :columns columns)
50 (excl:usb8-array-to-base64-string usb8
55 (test string (base64-string-to-string
56 (excl:usb8-array-to-base64-string
64 (defun time-routines ()
65 (let* ((str "abcdefghijklmnopqwertyu1234589jhwf2ff")
66 (usb8 (string-to-usb8-array str))
67 (int 12345678901234567890)
69 (time-iterations n (integer-to-base64-string int))
70 (time-iterations n (excl:integer-to-base64-string int))
71 (time-iterations n (string-to-base64-string str))
72 (time-iterations n (excl:usb8-array-to-base64-string usb8))))
75 ;;#+run-test (test-base64)