1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; ID: $Id: assert.lisp,v 1.3 2003/08/04 12:28:46 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-msg (msg &optional format-str &rest args)
21 "Signal a test failure and exit the test."
22 (signal 'test-failure-condition
24 :format-control format-str
25 :format-arguments args))
27 (defun failure (format-str &rest args)
28 "Signal a test failure and exit the test."
29 (apply #'failure-msg nil format-str args))
31 (defmacro test-assert (test &optional msg)
33 (failure-msg ,msg "Test assertion: ~s" ',test)))
35 (defun assert-equal (v1 v2 &optional msg)
37 (failure-msg msg "Test equal: ~S ~S" v1 v2)))
39 (defmacro assert-true (v &optional msg)
41 (failure-msg msg "Not true: ~S" ',v)))
43 (defmacro assert-false (v &optional msg)
45 (failure-msg msg "Not false: ~S" ',v)))