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