From: Marco Baringer Date: Mon, 13 Mar 2006 21:54:03 +0000 (+0100) Subject: Added gen-buffer generator X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=a6753a0dbc0f074600d0bd7fc033d10955620ef4;p=fiveam.git Added gen-buffer generator --- diff --git a/src/packages.lisp b/src/packages.lisp index 3177b8b..7828de5 100644 --- a/src/packages.lisp +++ b/src/packages.lisp @@ -50,6 +50,7 @@ #:gen-character #:gen-string #:gen-list + #:gen-buffer ;; running tests #:run #:run-all-tests diff --git a/src/random.lisp b/src/random.lisp index f2d8a0a..e869a1c 100644 --- a/src/random.lisp +++ b/src/random.lisp @@ -234,5 +234,12 @@ producs objects." repeat (funcall length) collect (funcall elements)))) +(defun gen-buffer (&key (length (gen-integer :min 0 :max 50)) + (element-type '(unsigned-byte 8)) + (elements (gen-integer :min 0 :max (1- (expt 2 8))))) + (lambda () + (let ((buffer (make-array (funcall length) :element-type element-type))) + (map-into buffer elements)))) + ;;;; The trivial always-produce-the-same-thing generator is done using ;;;; cl:constantly.