X-Git-Url: http://git.kpe.io/?p=cl-base64.git;a=blobdiff_plain;f=base64-tests.lisp;fp=base64-tests.lisp;h=3b7ec4a22e1b090e1a58977b638c7bd170a46265;hp=0000000000000000000000000000000000000000;hb=0e74ef4c46d71c9e8ece1f0c9c185d4abbb06f44;hpb=7943dcc78d45dbb845a1fc6d2220dd732fdc6d53 diff --git a/base64-tests.lisp b/base64-tests.lisp new file mode 100644 index 0000000..3b7ec4a --- /dev/null +++ b/base64-tests.lisp @@ -0,0 +1,75 @@ +;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- +;;;; ************************************************************************* +;;;; FILE IDENTIFICATION +;;;; +;;;; Name: test.lisp +;;;; Purpose: Regression tests for cl-base64 +;;;; Programmer: Kevin M. Rosenberg +;;;; Date Started: Jan 2003 +;;;; +;;;; $Id: base64-tests.lisp,v 1.1 2003/04/15 15:34:43 kevin Exp $ +;;;; ************************************************************************* + +(in-package :cl-user) + +(defpackage #:base64-test + (:use #:cl #:kmrcl #:base64 #:util.test)) + +(in-package #:base64-test) + +(defun test-base64 () + (with-tests (:name "cl-base64 tests") + (do* ((length 0 (+ 3 length)) + (string (make-string length) (make-string length)) + (usb8 (make-usb8-array length) (make-usb8-array length)) + (integer (random (expt 10 length)) (random (expt 10 length)))) + ((>= length 300)) + (dotimes (i length) + (declare (fixnum i)) + (let ((code (random 256))) + (setf (schar string i) (code-char code)) + (setf (aref usb8 i) code))) + + (do* ((columns 0 (+ columns 4))) + ((> columns length)) + ;; Test against cl-base64 routines + (test integer (base64-string-to-integer + (integer-to-base64-string integer :columns columns))) + (test string (base64-string-to-string + (string-to-base64-string string :columns columns)) + :test #'string=) + + ;; Test against AllegroCL built-in routines + #+allegro + (progn + (test integer (excl:base64-string-to-integer + (integer-to-base64-string integer :columns columns))) + (test integer (base64-string-to-integer + (excl:integer-to-base64-string integer))) + (test (string-to-base64-string string :columns columns) + (excl:usb8-array-to-base64-string usb8 + (if (zerop columns) + nil + columns)) + :test #'string=) + (test string (base64-string-to-string + (excl:usb8-array-to-base64-string + usb8 + (if (zerop columns) + nil + columns))) + :test #'string=)))))) + + +(defun time-routines () + (let* ((str "abcdefghijklmnopqwertyu1234589jhwf2ff") + (usb8 (string-to-usb8-array str)) + (int 12345678901234567890) + (n 50000)) + (time-iterations n (integer-to-base64-string int)) + (time-iterations n (excl:integer-to-base64-string int)) + (time-iterations n (string-to-base64-string str)) + (time-iterations n (excl:usb8-array-to-base64-string usb8)))) + + +;;#+run-test (test-base64)