// -*- mode: C++; tab-width: 4; indent-tabs-mode: t; -*- vim:ts=4:sw=4 // // Copyright(c) Chong Kai Xiong (descender) // // This file is part of The Plains of Usata. // // The Plains of Usata is licensed under the GNU General Public // License (GPL) version 2. For details, please see the COPYING file // included in the software distribution, or visit // http://www.fsf.org/licenses/gpl.html. // // $Id: test.hpp,v 1.1 2005/01/03 09:47:14 Descender Exp $ #ifndef USATA_TEST_HPP #define USATA_TEST_HPP #include // Who says macros are evil? :) - descender #define USATA_TEST_ASSERT(expr) \ do { \ if ( !(expr) ) \ throw usata::test::Error(#expr); \ } while (0); \ namespace usata { namespace test { // NOTE: change this to a functor when necessary - descender typedef void (*Function)(); class Error : public std::exception { public: explicit Error(const std::string& msg) : m_msg(msg) {} virtual ~Error() throw() {} virtual const char *what() throw() { return m_msg.c_str(); } private: std::string m_msg; }; //! \brief Runs a test function //! \param[in] name Name for display purposes. //! \param[in] function Test function to run. bool run(const std::string& name, Function function) throw(); } } #endif