My Project
Loading...
Searching...
No Matches
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
6namespace CxxTest
7{
8 //
9 // TestSuite members
10 //
14
15 //
16 // Test-aborting stuff
17 //
18 static bool currentAbortTestOnFail = false;
19
21 {
23 }
24
25 void setAbortTestOnFail( bool value )
26 {
28 }
29
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__
#define CXXTEST_MAX_DUMP_SIZE
Definition: Flags.h:52
#define TS_ABORT()
Definition: TestSuite.h:31
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
Variable x
Definition: cfModGcd.cc:4082
virtual void setUp()
Definition: TestSuite.cpp:12
virtual ~TestSuite()
Definition: TestSuite.cpp:11
virtual void tearDown()
Definition: TestSuite.cpp:13
void trace(const char *file, unsigned line, const char *expression)
void failedAssertThrows(const char *file, unsigned line, const char *expression, const char *type, bool otherThrown)
void failedTest(const char *file, unsigned line, const char *expression)
void failedAssert(const char *file, unsigned line, const char *expression)
void warning(const char *file, unsigned line, const char *expression)
void failedAssertThrowsNot(const char *file, unsigned line, const char *expression)
void failedAssertSameData(const char *file, unsigned line, const char *xStr, const char *yStr, const char *sizeStr, const void *x, const void *y, unsigned size)
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:53
void message(int i, int *reduc, int *olddeg, kStrategy strat, int red_result)
Definition: kutil.cc:7512
static unsigned currentMaxDumpSize
Definition: TestSuite.cpp:41
bool abortTestOnFail()
Definition: TestSuite.cpp:20
void doFailAssert(const char *file, unsigned line, const char *expression, const char *message)
Definition: TestSuite.cpp:72
void doFailAssertThrows(const char *file, unsigned line, const char *expr, const char *type, bool otherThrown, const char *message)
Definition: TestSuite.cpp:115
unsigned maxDumpSize()
Definition: TestSuite.cpp:43
void doAbortTest()
Definition: TestSuite.cpp:30
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
void doFailAssertThrowsNot(const char *file, unsigned line, const char *expression, const char *message)
Definition: TestSuite.cpp:127
void doTrace(const char *file, unsigned line, const char *message)
Definition: TestSuite.cpp:56
void doWarn(const char *file, unsigned line, const char *message)
Definition: TestSuite.cpp:61
void setMaxDumpSize(unsigned value)
Definition: TestSuite.cpp:48
static bool currentAbortTestOnFail
Definition: TestSuite.cpp:18
void doFailTest(const char *file, unsigned line, const char *message)
Definition: TestSuite.cpp:66
TestTracker & tracker()
Definition: TestTracker.h:111
bool sameData(const void *x, const void *y, unsigned size)
Definition: TestSuite.cpp:81
void setAbortTestOnFail(bool value)
Definition: TestSuite.cpp:25