10 #include <QSharedPointer> 11 #include <QTextStream> 20 #define TEST_CONCATENATE_DETAIL(x, y) x##y 21 #define TEST_CONCATENATE(x, y) TEST_CONCATENATE_DETAIL(x, y) 22 #define TEST_MAKE_UNIQUE(x) TEST_CONCATENATE(x, __COUNTER__) 24 #define DECLARE_TEST(className) static edbee::test::Test<className> TEST_MAKE_UNIQUE(t)(#className) 25 #define DECLARE_NAMED_TEST(name,className) static edbee::test::Test<className> TEST_MAKE_UNIQUE(name)(#className) 28 namespace edbee {
namespace test {
42 return QString(
"%1").arg(obj);
73 virtual const char*
fileName() {
return fileNameRef_; }
78 virtual const char*
statement() {
return actualStatementRef_; }
92 const char* fileNameRef_;
96 bool compareStatement_;
97 const char* actualStatementRef_;
98 const char* expectedStatementRef_;
100 QString expectedValue_;
113 #define GET_3TH_ARG(arg1, arg2, arg3, ...) arg3 114 #define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4 117 #define testTrue_1(statement) testTrueImpl( ( statement ) ? true : false, #statement, "", __FILE__, __LINE__) 118 #define testTrue_2(statement, message) testTrueImpl( ( statement ) ? true : false, #statement, (message), __FILE__, __LINE__ ) 119 #define testTrue_MACRO_CHOOSER(...) \ 120 GET_3TH_ARG(__VA_ARGS__, testTrue_2, testTrue_1, ) 121 #define testTrue(...) testTrue_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__) 124 #define testFalse(statement) testTrue( !statement ) 127 #define testEqual_1(actual,expected) do { \ 128 QString actualStr = edbee::test::toQString(actual); \ 129 QString expectedStr = edbee::test::toQString(expected); \ 130 testEqualImpl( ( actualStr ) == ( expectedStr ), actualStr, expectedStr, #actual, #expected, "", __FILE__, __LINE__ ); \ 133 #define testEqual_2(actual,expected, message) do \ 134 QString actualStr = edbee::test::toQString(actual); \ 135 QString expectedStr = edbee::test::toQString(expected); \ 136 testEqualImpl( ( actualStr ) == ( expectedStr ), actualStr, expectedStr, #actual, #expected, (message), __FILE__, __LINE__ ); \ 140 #define testEqual_MACRO_CHOOSER(...) \ 141 GET_4TH_ARG(__VA_ARGS__, testEqual_2, testEqual_1, ) 142 #define testEqual(...) testEqual_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__) 145 #define testSkip(msg) testSkipImpl( msg, __FILE__, __LINE__) 174 virtual void testTrueImpl(
bool condition,
const char*
statement,
const QString&
description,
const char* file,
int line );
177 virtual void testEqualImpl(
bool result,
const QString& actual,
const QString& expected,
179 const QString& description,
const char* file,
int line );
181 virtual void testSkipImpl(
const QString& description,
const char* file,
int line );
185 virtual QString currentMethodName();
186 virtual void giveTestResultToEngine(
TestResult* result );
216 virtual void endTestRun(
TestEngine* engine );
220 virtual void startTestCase(
TestEngine* engine );
221 virtual void endTestCase(
TestEngine* engine );
225 virtual void startTestMethod(
TestEngine* engine );
226 virtual void endTestMethod(
TestEngine* engine );
261 virtual bool hasTest(
TestCase*
object);
262 virtual void addTest(
TestCase*
object);
263 virtual int runAll();
264 virtual int run(
TestCase*
object );
265 virtual int run(
const QString& name );
266 virtual void startRun();
267 virtual void endRun();
276 virtual const char*
currentClassName() {
return currentTestRef_->metaObject()->className(); }
281 virtual void giveTestResult(
TestResult* testResult );
288 QList<TestCase*> testRefList_;
293 QString currentMethodName_;
297 QList<TestResult*> testResultList_;
321 child->setObjectName(name);
virtual int lineNumber()
Definition: test.h:74
virtual void setSkip()
A skip test result.
Definition: test.cpp:70
virtual QString actualValue()
Definition: test.h:80
This method represents a test result.
Definition: test.h:47
virtual const char * currentClassName()
This method returns the current class name.
Definition: test.h:276
virtual const char * fileName()
Definition: test.h:73
virtual const char * statement()
Definition: test.h:78
virtual bool compareStatement()
Definition: test.h:76
virtual QString expectedValue()
Definition: test.h:81
virtual TestCase * testCae()
Definition: test.h:70
virtual const char * expectedStatement()
Definition: test.h:79
virtual Status status()
Definition: test.h:83
virtual void setOutputHandler(OutputHandler *handler)
Definition: test.h:270
QString toQString(const T &obj)
Definition: test.h:40
I really really hate the QTestLib output on my Mac. It's a very ugly xwindows console result...
Definition: test.h:161
virtual void setBooleanResult(bool result, const char *statement)
Sets the result and the state of the test.
Definition: test.cpp:44
virtual QString methodName()
Definition: test.h:71
Test(const QString &name)
Definition: test.h:319
virtual void setCompareResult(bool result, const QString &actualValue, const QString &expectedValue, const char *actualStatement, const char *expectedStatement)
Sets a compare result.
Definition: test.cpp:57
#define new
Definition: debug_new.h:33
Status
Definition: test.h:50
virtual QString currentMethodName()
This method returns the current method name.
Definition: test.h:279
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
This is the main test engine.
Definition: test.h:253
virtual QList< TestResult * > testResultList()
This method returns a list of test results.
Definition: test.h:284
QSharedPointer< T > child
Definition: test.h:317
TestEngine & engine()
Definition: test.h:306
virtual const char * actualStatement()
Definition: test.h:77
This is the basic outputhandler. The basic outputhandler simply executes a qDebug with the given info...
Definition: test.h:207
virtual ~TestResult()
Definition: test.h:55
TestResult(TestCase *testCase, const QString &methodName, const QString &description, const char *file, int lineNumber)
A single test result.
Definition: test.cpp:25
virtual QString description()
Definition: test.h:72
virtual TestEngine * engine()
This method returns the current engine.
Definition: test.h:168
virtual void addTest(TestCase *object)
this metohd adds a test
Definition: test.cpp:339
virtual void setEngine(TestEngine *engine)
Definition: test.h:169
virtual OutputHandler * outputHandler()
Definition: test.h:269
virtual TestCase * currentTest()
This method returns the current test.
Definition: test.h:273