1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
#ifndef __cxxtest__TestSuite_cpp__
#define __cxxtest__TestSuite_cpp__
#include <cxxtest/TestSuite.h>
namespace CxxTest
{
//
// TestSuite members
//
TestSuite::~TestSuite() {}
void TestSuite::setUp() {}
void TestSuite::tearDown() {}
//
// Test-aborting stuff
//
static bool currentAbortTestOnFail = false;
bool abortTestOnFail()
{
return currentAbortTestOnFail;
}
void setAbortTestOnFail( bool value )
{
currentAbortTestOnFail = value;
}
void doAbortTest()
{
# if defined(_CXXTEST_HAVE_EH)
if ( currentAbortTestOnFail )
throw AbortTest();
# endif // _CXXTEST_HAVE_EH
}
//
// Max dump size
//
static unsigned currentMaxDumpSize = CXXTEST_MAX_DUMP_SIZE;
unsigned maxDumpSize()
{
return currentMaxDumpSize;
}
void setMaxDumpSize( unsigned value )
{
currentMaxDumpSize = value;
}
//
// Some non-template functions
//
void doTrace( const char *file, unsigned line, const char *message )
{
tracker().trace( file, line, message );
}
void doWarn( const char *file, unsigned line, const char *message )
{
tracker().warning( file, line, message );
}
void doFailTest( const char *file, unsigned line, const char *message )
{
tracker().failedTest( file, line, message );
TS_ABORT();
}
void doFailAssert( const char *file, unsigned line,
const char *expression, const char *message )
{
if ( message )
tracker().failedTest( file, line, message );
tracker().failedAssert( file, line, expression );
TS_ABORT();
}
bool sameData( const void *x, const void *y, unsigned size )
{
if ( size == 0 )
return true;
if ( x == y )
return true;
if ( !x || !y )
return false;
const char *cx = (const char *)x;
const char *cy = (const char *)y;
while ( size -- )
if ( *cx++ != *cy++ )
return false;
return true;
}
void doAssertSameData( const char *file, unsigned line,
const char *xExpr, const void *x,
const char *yExpr, const void *y,
const char *sizeExpr, unsigned size,
const char *message )
{
if ( !sameData( x, y, size ) ) {
if ( message )
tracker().failedTest( file, line, message );
tracker().failedAssertSameData( file, line, xExpr, yExpr, sizeExpr, x, y, size );
TS_ABORT();
}
}
void doFailAssertThrows( const char *file, unsigned line,
const char *expr, const char *type,
bool otherThrown,
const char *message )
{
if ( message )
tracker().failedTest( file, line, message );
tracker().failedAssertThrows( file, line, expr, type, otherThrown );
TS_ABORT();
}
void doFailAssertThrowsNot( const char *file, unsigned line,
const char *expression, const char *message )
{
if ( message )
tracker().failedTest( file, line, message );
tracker().failedAssertThrowsNot( file, line, expression );
TS_ABORT();
}
}
#endif // __cxxtest__TestSuite_cpp__
|