PSCF v1.1
example3.cpp
1#define TEST_MPI
2
3#include "UnitTest.h"
4#include "UnitTestRunner.h"
5#include <iostream>
6
7
15class TestA : public UnitTest
16{
17
18public:
19
20 void test1() {
21 printMethod(TEST_FUNC);
22 if (mpiRank() == 0) {
23 TEST_ASSERT(true);
24 } else {
25 TEST_ASSERT(false);
26 }
27 }
28
29 void test2() {
30 printMethod(TEST_FUNC);
31 if (mpiRank() == 0) {
32 TEST_ASSERT(false);
33 } else {
34 TEST_ASSERT(true);
35 }
36 }
37
38 void test3() {
39 printMethod(TEST_FUNC);
40 if (mpiRank() == 0) {
41 TEST_ASSERT(false);
42 } else {
43 TEST_ASSERT(false);
44 }
45 }
46
47 void test4() {
48 printMethod(TEST_FUNC);
49 if (mpiRank() == 0) {
50 TEST_ASSERT(true);
51 } else {
52 TEST_ASSERT(true);
53 }
54 }
55
56};
57
58/*
59* Preprocessor macros to define an associated UnitTestRunner.
60*/
61TEST_BEGIN(TestA)
62TEST_ADD(TestA, test1)
63TEST_ADD(TestA, test2)
64TEST_ADD(TestA, test3)
65TEST_ADD(TestA, test4)
66TEST_END(TestA)
67
68int main()
69{
70 MPI::Init();
71 TestA_Runner test;
72 test.run();
73 MPI::Finalize();
74}
This example shows how to construct and run a single UnitTest class.
Definition: example1.cpp:21
UnitTest is a base class for classes that define unit tests.
Definition: UnitTest.h:51
void printMethod(const char *methodName)
Write name of a class method, iff ioProcessor.
Definition: UnitTest.h:314