X-Git-Url: http://git.kpe.io/?p=cl-base64.git;a=blobdiff_plain;f=tests.lisp;h=927e4b8c606c4bd270e58f236b3b42137d394068;hp=7e5d3ff656ecfae14f13b573336c581bf56be2e5;hb=refs%2Ftags%2Fdebian-3.3.3-2;hpb=ad3711f4713954accfce438e2895aa06e3f6bf19 diff --git a/tests.lisp b/tests.lisp index 7e5d3ff..927e4b8 100644 --- a/tests.lisp +++ b/tests.lisp @@ -21,53 +21,53 @@ (with-tests (:name "cl-base64 tests") (let ((*break-on-test-failures* t)) (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=)))))) + (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=)))))) t) (defun time-routines () (let* ((str "abcdefghijklmnopqwertyu1234589jhwf2ff") - (usb8 (string-to-usb8-array str)) - (int 12345678901234567890) - (n 50000)) + (usb8 (string-to-usb8-array str)) + (int 12345678901234567890) + (n 50000)) (time-iterations n (integer-to-base64-string int)) (time-iterations n (string-to-base64-string str)) #+allego @@ -75,5 +75,5 @@ (time-iterations n (excl:integer-to-base64-string int)) (time-iterations n (excl:usb8-array-to-base64-string usb8))))) - + ;;#+run-test (test-base64)