1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; ID: $Id: assert.lisp,v 1.2 2003/08/04 12:16:13 kevin Exp $
6 ;;;; Purpose: Assert functions for XLUnit
8 ;;;; *************************************************************************
15 (define-condition test-failure-condition (simple-condition)
16 ((msg :initform nil :initarg :msg :accessor msg))
17 (:documentation "Base class for all test failures."))
20 (defun failure (format-str &rest args)
21 "Signal a test failure and exit the test."
22 (signal 'test-failure-condition
23 :format-control format-str
24 :format-arguments args))
26 (defmacro test-assert (test &optional msg)
28 (failure "Test assertion: ~s" ',test)))
30 (defun assert-equal (v1 v2 &optional msg)
32 (failure "Test equal: ~s ~s" v1 v2)))
34 (defun assert-true (v &optional msg)
36 (failure "Test true: ~s [~A]" v (if msg msg ""))))
38 (defun assert-false (v &optional msg)
40 (failure "Test false ~A" (if msg msg ""))))