hshgtest.h File Reference

#include <string>
#include <cstdlib>
#include <ostream>

Go to the source code of this file.

Namespaces

namespace  HSHGTest

Classes

class  HSHGTest::TestFailure
 An exception class representing a test assertion failure. More...
struct  HSHGTest::TestFn
 Helper structure for defining named test functions. More...

Defines

#define HSHG_BEGIN_TESTS   namespace { HSHGTest::TestFn tests[] = {
 Begins the declaration of a block of tests.
#define HSHG_TEST_ENTRY(t)   { #t, t },
 Defines a test function.
#define HSHG_END_TESTS   { NULL, NULL } }; }
 Ends the declaration of a block of tests.
#define HSHG_TEST_MAIN   int main() { return HSHGTest::RunTests( tests, std::cout ); }
 Defines a default main function for a test executable.
#define HSHG_ASSERT(x)   HSHGTest::TestAssert( x, #x, __FILE__, __LINE__ )
#define HSHG_ASSERT_DESC(x, d)   HSHGTest::TestAssert( x, d, __FILE__, __LINE__ )
#define HSHG_ASSERT_THROWS(x, except)

Functions

void HSHGTest::TestAssert (bool condition, const char *message, const char *file, unsigned int line)
 Throws a TestFailure exception if the given condition is false.
int HSHGTest::RunTests (TestFn fnarray[], std::ostream &log)
 Runs a sequence of tests.


Define Documentation

#define HSHG_ASSERT (  )     HSHGTest::TestAssert( x, #x, __FILE__, __LINE__ )

Calls the HSHGTest::TestAssert function with the given condition, a stringized version of the condition for a description and appropriate file and line numbers.

#define HSHG_ASSERT_DESC ( x,
 )     HSHGTest::TestAssert( x, d, __FILE__, __LINE__ )

Calls the HSHGTest::TestAssert function with the given condition, a supplied description and appropriate file and line numbers.

#define HSHG_ASSERT_THROWS ( x,
except   ) 

Value:

try { x;\
        HSHGTest::TestAssert( false, "Exception " #except " expected."\
                , __FILE__, __LINE__ ); } catch( except & ) {}
Calls the HSHGTest::TestAssert function with false if the given expression doesn't cause an exception (other than a TestFailure) that can be caught by a catch block of the form "catch (except&)" for the given macro parameter except.

#define HSHG_BEGIN_TESTS   namespace { HSHGTest::TestFn tests[] = {

Begins the declaration of a block of tests.

#define HSHG_END_TESTS   { NULL, NULL } }; }

Ends the declaration of a block of tests.

#define HSHG_TEST_ENTRY (  )     { #t, t },

Defines a test function.

The test function must have a definition or a prototype in scope at the point at which this macro is used.

#define HSHG_TEST_MAIN   int main() { return HSHGTest::RunTests( tests, std::cout ); }

Defines a default main function for a test executable.


Generated on Wed Oct 31 00:18:54 2007 by  doxygen 1.5.2