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