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
|
/***************************************************************************
* Copyright (C) 2007 Nicolas Hadacek <hadacek@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef MAIN_TEST_H
#define MAIN_TEST_H
#include "common/global/about.h"
//----------------------------------------------------------------------------
#define TEST_SKIPPED_RETURN { skipped(); return false; }
#define TEST_FAILED_RETURN(message) { failed(message, __FILE__, __LINE__); return false; }
#define TEST_FAILED(message) { failed(message, __FILE__, __LINE__); }
#define TEST_PASSED { printf("."); fflush(stdout); passed(); }
#define TEST_MAIN(Type) \
int main(int argc, char **argv) \
{ \
Type *check = new Type; \
Piklab::OptionList opt = check->optionList(); \
Piklab::init(new Piklab::AboutData("test", 0, 0), argc, argv, false, opt.ptr()); \
check->runTest(); \
return 0; \
}
//----------------------------------------------------------------------------
class Test
{
public:
Test();
virtual Piklab::OptionList optionList() const { return Piklab::OptionList(); }
virtual void runTest();
protected:
KCmdLineArgs *_args;
TQString _message;
void passed() { _nbPassed++; }
void failed(const TQString &message, const char *file, int line);
void skipped() { _nbSkipped++; }
virtual bool execute() = 0; // returns false if failed or skipped
virtual void checkArguments() {}
private:
uint _nbPassed, _nbFailed, _nbSkipped;
};
#endif
|