File: tests.lisp

package info (click to toggle)
cl-photo 0.14-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 116 kB
  • ctags: 66
  • sloc: lisp: 739; makefile: 49; sh: 28
file content (136 lines) | stat: -rw-r--r-- 3,959 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
;;;; -*- 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.01))
          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
 :fov.1 (fov 50 24 16 :magnification 1 :units :mm)
 24 16 28.8444 1 100 100)

(def-numeric-test
 :fov.2 (fov 50 24 16 :magnification 1 :units :feet)
  0.07874 0.052494 0.094634 1 0.328084 100)

(def-numeric-test
 :fov.3 (fov 50 24 16 :image-distance 100 :units :mm)
 24 16 28.8444 1 100 100)

(def-numeric-test
 :fov.4 (fov 50 24 16 :image-distance 100 :units :feet)
  0.07874 0.052494 0.094634 1 0.328084 100)

(def-numeric-test
 :fov.5 (fov 50 24 16 :object-distance 100 :units :mm)
 24 16 28.8444 1 100 100)

(def-numeric-test
 :fov.6 (fov 50 24 16 :object-distance (cl-photo::mm->feet 100) :units :feet)
  0.07874 0.052494 0.094634 1 0.328084 100)

(def-numeric-test
 :mag.1 (magnification :focal-length 50 :image-distance 100 :units :mm) 1)

(def-numeric-test
 :mag.2 (magnification :focal-length 50 :image-distance 100 :units :feet) 1)

(def-numeric-test
 :mag.3 (magnification :focal-length 50 :object-distance 100 :units :mm) 1)

(def-numeric-test
 :mag.4 (magnification :focal-length 50 :object-distance (cl-photo::mm->feet 100)
                       :units :feet) 1)

(def-numeric-test
 :mag.5 (magnification :image-distance 100 :object-distance 100 :units :mm) 1)

(def-numeric-test
 :mag.6 (magnification :image-distance 100 :object-distance (cl-photo::mm->feet 100)
                       :units :feet) 1)

(def-numeric-test
    :cu.1 (close-up :focal-length 65 :magnification 5 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.2 (close-up :focal-length 65 :object-distance 78 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.3 (close-up :focal-length 65 :image-distance 390 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.4 (close-up :object-distance 78 :image-distance 390 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.5 (close-up :object-distance 78 :magnification 5 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.6 (close-up :image-distance 390 :magnification 5 :units :mm)
  65 78 390 5 6)

(def-numeric-test
    :cu.7 (close-up :focal-length 65 :magnification 5 :units :feet)
  65 0.2559055 390 5 6)

(def-numeric-test
    :cu.8 (close-up :focal-length 65 :object-distance 0.2559055 :units :feet)
  65 0.2559055 390 5 6)

(def-numeric-test
    :cu.9 (close-up :focal-length 65 :image-distance 390 :units :feet)
  65 0.2559055 390 5 6)

(def-numeric-test
    :cu.10 (close-up :object-distance 0.2559055 :image-distance 390 :units :feet)
  65 0.2559055 390 5 6)

(def-numeric-test
    :cu.11 (close-up :object-distance 0.2559055 :magnification 5 :units :feet)
  65 0.2559055 390 5 6)

(def-numeric-test
    :cu.12 (close-up :image-distance 390 :magnification 5 :units :feet)
  65 0.2559055 390 5 6)