1
#ifndef CPPUNIT_EXTENSIONS_ORTHODOX_H
2
#define CPPUNIT_EXTENSIONS_ORTHODOX_H
4
#include <cppunit/TestCase.h>
10
* Orthodox performs a simple set of tests on an arbitary
11
* class to make sure that it supports at least the
12
* following operations:
14
* default construction - constructor
15
* equality/inequality - operator== && operator!=
16
* assignment - operator=
17
* negation - operator!
18
* safe passage - copy construction
20
* If operations for each of these are not declared
21
* the template will not instantiate. If it does
22
* instantiate, tests are performed to make sure
23
* that the operations have correct semantics.
25
* Adding an orthodox test to a suite is very
28
* public: Test *suite () {
29
* TestSuite *suiteOfTests = new TestSuite;
30
* suiteOfTests->addTest (new ComplexNumberTest ("testAdd");
31
* suiteOfTests->addTest (new TestCaller<Orthodox<Complex> > ());
32
* return suiteOfTests;
35
* Templated test cases be very useful when you are want to
36
* make sure that a group of classes have the same form.
42
template <class ClassUnderTest> class Orthodox : public TestCase
45
Orthodox () : TestCase ("Orthodox") {}
48
ClassUnderTest call (ClassUnderTest object);
55
// Run an orthodoxy test
56
template <class ClassUnderTest> void Orthodox<ClassUnderTest>::runTest ()
58
// make sure we have a default constructor
59
ClassUnderTest a, b, c;
61
// make sure we have an equality operator
62
CPPUNIT_ASSERT (a == b);
65
b.operator= (a.operator! ());
66
CPPUNIT_ASSERT (a != b);
70
CPPUNIT_ASSERT (a == b);
77
CPPUNIT_ASSERT (c == call (a));
80
CPPUNIT_ASSERT (c == call (b));
86
template <class ClassUnderTest>
87
ClassUnderTest Orthodox<ClassUnderTest>::call (ClassUnderTest object)