r10471: add tests, improve fov and magnification function
[cl-photo.git] / tests.lisp
diff --git a/tests.lisp b/tests.lisp
new file mode 100644 (file)
index 0000000..605e288
--- /dev/null
@@ -0,0 +1,45 @@
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          cl-photo-tests.lisp
+;;;; Purpose:       Cl-Photo tests file
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Apr 2003
+;;;;
+;;;; $Id$
+;;;;
+;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
+;;;; *************************************************************************
+
+(defpackage #:cl-photo-tests
+  (:use #:cl-photo #:cl #:rtest #:kmrcl))
+(in-package #:cl-photo-tests)
+
+(rem-all-tests)
+
+(defun verify-results (alist blist)
+  (every #'identity
+         (mapcar
+          (lambda (a b) (numbers-within-percentage a b 0.001))
+          alist blist)))
+
+(defmacro def-numeric-test (name test &rest values)
+  `(deftest ,name
+            (let ((results (multiple-value-list ,test)))
+              (verify-results results ',values))
+            t))
+
+(def-numeric-test
+ :gl.1 (gaussian-lens :focal-length 50 :object-distance 100) 100)
+
+(def-numeric-test
+ :gl.2 (gaussian-lens :focal-length 50 :image-distance 200) 66.66667)
+
+(def-numeric-test
+ :gl.3 (gaussian-lens :object-distance 100 :image-distance 100) 50)
+
+(def-numeric-test
+ :aov.1 (aov 50 36 24) 39.5977 26.9915 46.7930)
+(def-numeric-test 
\ No newline at end of file