;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 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 :xomo-test.model) (deftestsuite fresh-default-xomo-db-test-suite-mixin (fresh-db-test-suite-mixin) () :setup (progn (register-db-default-configuration-list 'test-xomo-default-configurations (xomo-defaults)) (init-db))) (deftestsuite coc-lib-xomo-test-suite (fresh-default-xomo-db-test-suite-mixin xomo-tests) ()) (addtest check-coco-numbers (ensure-same (coco '(1 2 3)) '(1 2 3) :report "converting cocomo numbers to canonical form")) (addtest check-coco-names (ensure-same (coco '(vl l n)) '(1 2 3) :report "converting cocomo names to canonical form")) (addtest check-coco-mix (ensure-same (coco '(vl 2 n)) '(1 2 3) :report "converting cocomo numbers and names to canonical form")) (addtest check-coco-invalid (ensure-warning (coco '(invalid)))) (addtest check-coco-restrict (ensure-same (coco-restrict '(1 2 3) '(2 3 4)) '(2 3) :test #'subset-compare-equalp)) (addtest check-coco-restrict-non-intersect (ensure-warning (coco-restrict '(1 2 ) '(4 5)))) (addtest check-guess-one-a (let ((ai (make-one-a :min 2.0 :max 11.0))) (ensure-no-warning (guess ai)) (ensure (typep (guess ai) 'number)) (ensure (<= 2.0 (guess ai) 11.0)))) (addtest check-guess-one-b (let ((bi (make-one-b :min 0.5 :max 1.0))) (ensure-no-warning (guess bi)) (ensure (typep (guess bi) 'number)) (ensure (<= 0.5 (guess bi) 1.0)))) (addtest check-guess-one-b-correlation (let ((bi (make-one-b :min 0.5 :max 1.0)) (*a-b-correlation* (point-to-line 2 1 10 0.6)) (*a-b-correlation-wiggle* (make-num :min -0.1 :max 0.0))) (ensure-no-warning (guess bi)) (ensure (typep (guess bi) 'number)) (ensure (<= 0.5 (guess bi) 1.0)))) (addtest check-guess-one-c (let ((ci (make-one-c :min 3.0 :max 3.67))) (ensure-no-warning (guess ci)) (ensure (typep (guess ci) 'number)) (ensure (<= 3.0 (guess ci) 3.67)))) (addtest check-guess-one-d (let ((di (make-one-d :min 0.28 :max 0.33))) (ensure-no-warning (guess di)) (ensure (typep (guess di) 'number)) (ensure (<= 0.28 (guess di) 0.33)))) (addtest check-guess-sf (let ((sfi (make-sf :range '(1 2 3 4) :effort (make-num :min 0 :max 1) :rsf (make-num :min 0 :max 1) :dsf (make-num :min 0 :max 1) :csf (make-num :min 0 :max 1)))) (ensure-no-warning (guess sfi)) (ensure (typep (guess sfi) 'xomo.model:sf)))) (addtest check-guess-em (let ((emi (make-em :range '(1 2 3 4) :effort (make-num :min 0 :max 1) :rin (make-num :min 0 :max 1) :din (make-num :min 0 :max 1) :cin (make-num :min 0 :max 1)))) (ensure-no-warning (guess emi)) (ensure (typep (guess emi) 'xomo.model:em)))) (addtest check-guess-augmented-em (let ((emi (make-augmented-em :range '(1 2 3 4) :effort (make-num :min 0 :max 1) :rin (make-num :min 0 :max 1) :din (make-num :min 0 :max 1) :cin (make-num :min 0 :max 1) :augment-range-fn #'(lambda (r) r)))) (ensure-no-warning (guess emi)) (ensure (typep (guess emi) 'xomo.model:em)))) (addtest check-guess-dr (let ((dri (make-dr :range '(1 2 3 4) :rout (make-num :min 0 :max 1) :dout (make-num :min 0 :max 1) :cout (make-num :min 0 :max 1)))) (ensure-no-warning (guess dri)) (ensure (typep (guess dri) 'xomo.model:dr)))) (addtest check-expand-range-error (ensure-error (expand-range 5 2))) (addtest check-expand-range-default (ensure-same (expand-range 1 5) '(1 2 3 4 5) :test #'equalp)) (addtest check-expand-range-over-1 (ensure-same (expand-range 1 5 2) '(1 3 5) :test #'equalp)) (addtest check-expand-range-under-1 (ensure-same (expand-range 1 5 0.5 1) '(1 1.5 2 2.5 3 3.5 4 4.5 5) :test #'equalp)) (addtest check-pivoted-line (ensure-same (pivoted-line 3 (- 1 (random 2.0))) ;;any m should be 1 1 :test #'=) (ensure-same (pivoted-line 2 0.5) 0.5 :test #'=) (ensure-same (pivoted-line 4 -0.5) 0.5 :test #'=)) (addtest check-hinged-line (ensure-same (hinged-line 6 (- 1 (random 2.0))) ;;any m should be 0 0 :test #'=) (ensure-same (hinged-line 3 0.5) -1.5 :test #'=) (ensure-same (hinged-line 1 -0.5) 2.5 :test #'=)) (addtest check-hinged-line-coqualmo (ensure-same (hinged-line-coqualmo 1 (- 1 (random 2.0))) ;;any m should be 0 0 :test #'=) (ensure-same (hinged-line-coqualmo 3 0.5) 1 :test #'=) (ensure-same (hinged-line-coqualmo 6 -0.5) -2.5 :test #'=)) (addtest check-em2* (let ((sym 'acap)) (ensure-no-warning (em2effort sym)) (ensure (numberp (em2effort sym))) (ensure-no-warning (em2rin sym)) (ensure (numberp (em2rin sym))) (ensure-no-warning (em2din sym)) (ensure (numberp (em2din sym))) (ensure-no-warning (em2cin sym)) (ensure (numberp (em2cin sym))))) (addtest check-sf2* (let ((sym 'flex)) (ensure-no-warning (sf2effort sym)) (ensure (numberp (sf2effort sym))) (ensure-no-warning (sf2rin sym)) (ensure (numberp (sf2rin sym))) (ensure-no-warning (sf2din sym)) (ensure (numberp (sf2din sym))) (ensure-no-warning (sf2cin sym)) (ensure (numberp (sf2cin sym))))) (addtest check-dr2* (let ((sym 'etat)) (ensure-no-warning (dr2rout sym)) (ensure (numberp (dr2rout sym))) (ensure-no-warning (dr2dout sym)) (ensure (numberp (dr2dout sym))) (ensure-no-warning (dr2cout sym)) (ensure (numberp (dr2cout sym)))))