Use the local exerr in print-errors.
[lisp-unit.git] / internal-test / example-tests.lisp
blob1bb1f37144a86f401374846fdd2c20e3f1bf4ae8
1 #|
3 LISP-UNIT Example Tests
5 Copyright (c) 2010-2012, Thomas M. Hermann
6 All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
12 o Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 o Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in
16 the documentation and/or other materials provided with the
17 distribution.
18 o The names of the contributors may not be used to endorse or promote
19 products derived from this software without specific prior written
20 permission.
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
26 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 (in-package :lisp-unit)
38 (defun my-max (x y)
39 "Deliberately wrong"
40 (declare (ignore y))
43 (define-test test-my-max
44 ;; Wrong
45 (assert-equal 5 (my-max 2 5))
46 (assert-equal 5 (my-max 5 2))
47 (assert-equal 10 (my-max 10 10))
48 (assert-equal 0 (my-max -5 0))
49 ;; Error
50 (assert-equal 5 (my-max-err 2 5)))
52 (defun my-sqrt (n)
53 "Not really."
54 (/ n 2))
56 (define-test my-sqrt
57 (dotimes (i 5)
58 (assert-equal i (my-sqrt (* i i)) i)))