PSCF
v1.1
src
test
examples
example3.cpp
1
#define TEST_MPI
2
3
#include "UnitTest.h"
4
#include "UnitTestRunner.h"
5
#include <iostream>
6
7
15
class
TestA
:
public
UnitTest
16
{
17
18
public
:
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
*/
61
TEST_BEGIN(
TestA
)
62
TEST_ADD(
TestA
, test1)
63
TEST_ADD(
TestA
, test2)
64
TEST_ADD(
TestA
, test3)
65
TEST_ADD(
TestA
, test4)
66
TEST_END(
TestA
)
67
68
int
main()
69
{
70
MPI::Init();
71
TestA_Runner test;
72
test.run();
73
MPI::Finalize();
74
}
TestA
This example shows how to construct and run a single UnitTest class.
Definition:
example1.cpp:21
UnitTest
UnitTest is a base class for classes that define unit tests.
Definition:
UnitTest.h:51
UnitTest::printMethod
void printMethod(const char *methodName)
Write name of a class method, iff ioProcessor.
Definition:
UnitTest.h:314
Generated on Wed Sep 20 2023 00:52:46 for PSCF by
1.9.5