1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; ID: $Id: assert.lisp,v 1.4 2003/08/04 16:13:58 kevin Exp $
6 ;;;; Purpose: Assert functions for XLUnit
8 ;;;; *************************************************************************
13 (define-condition assertion-failed (simple-condition)
14 ((msg :initform nil :initarg :msg :accessor msg))
15 (:documentation "Base class for all test failures."))
18 (defun failure-msg (msg &optional format-str &rest args)
19 "Signal a test failure and exit the test."
20 (signal 'assertion-failed
22 :format-control format-str
23 :format-arguments args))
25 (defun failure (format-str &rest args)
26 "Signal a test failure and exit the test."
27 (apply #'failure-msg nil format-str args))
29 (defun assert-equal (v1 v2 &optional msg)
31 (failure-msg msg "Test equal: ~S ~S" v1 v2)))
33 (defun assert-eql (v1 v2 &optional msg)
35 (failure-msg msg "Test eql: ~S ~S" v1 v2)))
37 (defmacro assert-true (v &optional msg)
39 (failure-msg msg "Not true: ~S" ',v)))
41 (defmacro assert-false (v &optional msg)
43 (failure-msg msg "Not false: ~S" ',v)))