11
|
1 |
/*
|
|
2 |
* Copyright (C) 2008 Remko Troncon
|
|
3 |
* Licensed under the MIT license.
|
|
4 |
* See COPYING for license details.
|
|
5 |
*/
|
|
6 |
|
|
7 |
#ifndef QtTestUtil_TestRegistration_H
|
|
8 |
#define QtTestUtil_TestRegistration_H
|
|
9 |
|
|
10 |
#include "QtTestUtil/TestRegistry.h"
|
|
11 |
|
|
12 |
namespace QtTestUtil {
|
|
13 |
|
|
14 |
/**
|
|
15 |
* A wrapper class around a test to manage registration and static
|
|
16 |
* creation of an instance of the test class.
|
|
17 |
* This class is used by QTTESTUTIL_REGISTER_TEST(), and you should not
|
|
18 |
* use this class directly.
|
|
19 |
*/
|
|
20 |
template<typename TestClass>
|
|
21 |
class TestRegistration {
|
|
22 |
public:
|
|
23 |
TestRegistration() {
|
|
24 |
test_ = new TestClass();
|
|
25 |
TestRegistry::getInstance()->registerTest(test_);
|
|
26 |
}
|
|
27 |
|
|
28 |
~TestRegistration() {
|
|
29 |
delete test_;
|
|
30 |
}
|
|
31 |
|
|
32 |
private:
|
|
33 |
TestClass* test_;
|
|
34 |
};
|
|
35 |
|
|
36 |
}
|
|
37 |
|
|
38 |
#endif
|