From a6753a0dbc0f074600d0bd7fc033d10955620ef4 Mon Sep 17 00:00:00 2001 From: Marco Baringer Date: Mon, 13 Mar 2006 22:54:03 +0100 Subject: [PATCH] Added gen-buffer generator --- src/packages.lisp | 1 + src/random.lisp | 7 +++++++ 2 files changed, 8 insertions(+) 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. -- 1.7.10.4