4
// $Id: //poco/1.2/CppUnit/include/CppUnit/Orthodox.h#1 $
8
#ifndef CppUnit_Orthodox_INCLUDED
9
#define CppUnit_Orthodox_INCLUDED
12
#include "CppUnit/CppUnit.h"
13
#include "CppUnit/TestCase.h"
20
* Orthodox performs a simple set of tests on an arbitary
21
* class to make sure that it supports at least the
22
* following operations:
24
* default construction - constructor
25
* equality/inequality - operator== && operator!=
26
* assignment - operator=
27
* negation - operator!
28
* safe passage - copy construction
30
* If operations for each of these are not declared
31
* the template will not instantiate. If it does
32
* instantiate, tests are performed to make sure
33
* that the operations have correct semantics.
35
* Adding an orthodox test to a suite is very
38
* public: Test *suite () {
39
* TestSuite *suiteOfTests = new TestSuite;
40
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
41
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
42
* return suiteOfTests;
45
* Templated test cases be very useful when you are want to
46
* make sure that a group of classes have the same form.
50
template <class ClassUnderTest>
51
class Orthodox: public TestCase
54
Orthodox(): TestCase("Orthodox")
59
ClassUnderTest call(ClassUnderTest object);
64
// Run an orthodoxy test
65
template <class ClassUnderTest>
66
void Orthodox<ClassUnderTest>::runTest()
68
// make sure we have a default constructor
69
ClassUnderTest a, b, c;
71
// make sure we have an equality operator
75
b.operator= (a.operator! ());
87
assert (c == call (a));
90
assert (c == call (b));
95
template <class ClassUnderTest>
96
ClassUnderTest Orthodox<ClassUnderTest>::call(ClassUnderTest object)
102
} // namespace CppUnit
105
#endif // CppUnit_Orthodox_INCLUDED