Update domain name to kpe.io
[cl-photo.git] / tests.lisp
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:          cl-photo-tests.lisp
6 ;;;; Purpose:       Cl-Photo tests file
7 ;;;; Programmer:    Kevin M. Rosenberg
8 ;;;; Date Started:  Apr 2003
9 ;;;;
10 ;;;; $Id$
11 ;;;;
12 ;;;; This file is Copyright (c) 2000-2003 by Kevin M. Rosenberg
13 ;;;; *************************************************************************
14
15 (defpackage #:cl-photo-tests
16   (:use #:cl-photo #:cl #:rtest #:kmrcl))
17 (in-package #:cl-photo-tests)
18
19 (rem-all-tests)
20
21 (defun verify-results (alist blist)
22   (every #'identity
23          (mapcar
24           (lambda (a b) (numbers-within-percentage a b 0.01))
25           alist blist)))
26
27 (defmacro def-numeric-test (name test &rest values)
28   `(deftest ,name
29             (let ((results (multiple-value-list ,test)))
30               (verify-results results ',values))
31             t))
32
33 (def-numeric-test
34  :gl.1 (gaussian-lens :focal-length 50 :object-distance 100) 100)
35
36 (def-numeric-test
37  :gl.2 (gaussian-lens :focal-length 50 :image-distance 200) 66.66667)
38
39 (def-numeric-test
40  :gl.3 (gaussian-lens :object-distance 100 :image-distance 100) 50)
41
42 (def-numeric-test
43  :aov.1 (aov 50 36 24) 39.5977 26.9915 46.7930)
44
45 (def-numeric-test
46  :fov.1 (fov 50 24 16 :magnification 1 :units :mm)
47  24 16 28.8444 1 100 100)
48
49 (def-numeric-test
50  :fov.2 (fov 50 24 16 :magnification 1 :units :feet)
51   0.07874 0.052494 0.094634 1 0.328084 100)
52
53 (def-numeric-test
54  :fov.3 (fov 50 24 16 :image-distance 100 :units :mm)
55  24 16 28.8444 1 100 100)
56
57 (def-numeric-test
58  :fov.4 (fov 50 24 16 :image-distance 100 :units :feet)
59   0.07874 0.052494 0.094634 1 0.328084 100)
60
61 (def-numeric-test
62  :fov.5 (fov 50 24 16 :object-distance 100 :units :mm)
63  24 16 28.8444 1 100 100)
64
65 (def-numeric-test
66  :fov.6 (fov 50 24 16 :object-distance (cl-photo::mm->feet 100) :units :feet)
67   0.07874 0.052494 0.094634 1 0.328084 100)
68
69 (def-numeric-test
70  :mag.1 (magnification :focal-length 50 :image-distance 100 :units :mm) 1)
71
72 (def-numeric-test
73  :mag.2 (magnification :focal-length 50 :image-distance 100 :units :feet) 1)
74
75 (def-numeric-test
76  :mag.3 (magnification :focal-length 50 :object-distance 100 :units :mm) 1)
77
78 (def-numeric-test
79  :mag.4 (magnification :focal-length 50 :object-distance (cl-photo::mm->feet 100)
80                        :units :feet) 1)
81
82 (def-numeric-test
83  :mag.5 (magnification :image-distance 100 :object-distance 100 :units :mm) 1)
84
85 (def-numeric-test
86  :mag.6 (magnification :image-distance 100 :object-distance (cl-photo::mm->feet 100)
87                        :units :feet) 1)
88
89 (def-numeric-test
90     :cu.1 (close-up :focal-length 65 :magnification 5 :units :mm)
91   65 78 390 5 6)
92
93 (def-numeric-test
94     :cu.2 (close-up :focal-length 65 :object-distance 78 :units :mm)
95   65 78 390 5 6)
96
97 (def-numeric-test
98     :cu.3 (close-up :focal-length 65 :image-distance 390 :units :mm)
99   65 78 390 5 6)
100
101 (def-numeric-test
102     :cu.4 (close-up :object-distance 78 :image-distance 390 :units :mm)
103   65 78 390 5 6)
104
105 (def-numeric-test
106     :cu.5 (close-up :object-distance 78 :magnification 5 :units :mm)
107   65 78 390 5 6)
108
109 (def-numeric-test
110     :cu.6 (close-up :image-distance 390 :magnification 5 :units :mm)
111   65 78 390 5 6)
112
113 (def-numeric-test
114     :cu.7 (close-up :focal-length 65 :magnification 5 :units :feet)
115   65 0.2559055 390 5 6)
116
117 (def-numeric-test
118     :cu.8 (close-up :focal-length 65 :object-distance 0.2559055 :units :feet)
119   65 0.2559055 390 5 6)
120
121 (def-numeric-test
122     :cu.9 (close-up :focal-length 65 :image-distance 390 :units :feet)
123   65 0.2559055 390 5 6)
124
125 (def-numeric-test
126     :cu.10 (close-up :object-distance 0.2559055 :image-distance 390 :units :feet)
127   65 0.2559055 390 5 6)
128
129 (def-numeric-test
130     :cu.11 (close-up :object-distance 0.2559055 :magnification 5 :units :feet)
131   65 0.2559055 390 5 6)
132
133 (def-numeric-test
134     :cu.12 (close-up :image-distance 390 :magnification 5 :units :feet)
135   65 0.2559055 390 5 6)
136