;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This file is part of "NOVA": NOVA = search + COCOMO tools ; Copyright, 2008, Tim Menzies tim@menzies.us ; ; NOVA is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; NOVA is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should have received a copy of the GNU General Public License ; a long with NOVA. If not, see . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package :wvu-lib-test.tricks) (deftestsuite random-lib-test-suite (wvu-lib-tests) () (:dynamic-variables (*seed*)) (:setup (setf *seed* *seed0*))) (addtest check-reset-seed (let (first-values second-values) (dotimes (x 10) (push (park-miller-randomizer) first-values)) (reset-seed) (dotimes (x 10) (push (park-miller-randomizer) second-values)) (ensure-same first-values second-values :test #'equalp))) (addtest check-reset-seed-specify-seed (let ((test-seed 5) first-values second-values third-values) (dotimes (x 10) (push (park-miller-randomizer) first-values)) (reset-seed test-seed) (dotimes (x 10) (push (park-miller-randomizer) second-values)) (reset-seed test-seed) (dotimes (x 10) (push (park-miller-randomizer) third-values)) (ensure-different first-values second-values :test #'equalp) (ensure-same second-values third-values :test #'equalp))) (addtest check-park-miller-randomizer (dotimes (i 10) (let ((rnd (park-miller-randomizer))) (ensure (< 0 rnd)) (ensure (<= rnd 1))))) (addtest check-my-random (let ((n 10)) (dotimes (i 10) (let ((rnd (my-random n))) (ensure (<= 0 rnd)) (ensure (< rnd n)))))) (addtest check-my-random-int (let ((n 10)) (dotimes (i 10) (let ((rnd-int (my-random-int n))) (ensure (integerp rnd-int)) (ensure (<= 0 rnd-int (1- n)))))))