Bridge++
Ver. 2.0.2
test.cpp
Go to the documentation of this file.
1
14
#include "
test.h
"
15
#include "
Parameters/commonParameters.h
"
16
17
#include "
IO/bridgeIO.h
"
18
using
Bridge::vout
;
19
20
#ifdef USE_TESTMANAGER
21
#include "
testManager.h
"
22
#endif
23
24
// utility routines for verifying test result.
25
26
namespace
Test
{
27
int
verify
(
const
double
result,
const
double
expected,
double
eps)
28
{
29
const
Bridge::VerboseLevel
vl
=
CommonParameters::Vlevel
();
30
31
int
verify_result = 0;
// 0 for successful, 1 for failure.
32
33
int
precision =
default_precision
;
34
35
#if USE_TESTMANAGER
36
// obtain current precision specified through menu.
37
precision =
TestManager::Instance
().
getCheckPrecision
();
38
#endif
39
40
if
(fabs(eps) <
CommonParameters::epsilon_criterion
()) {
// if eps is unspecified
41
eps = pow(10.0, -precision);
42
}
43
44
vout
.
general
(
vl
,
"\n"
);
45
vout
.
general
(
vl
,
"check test data\n"
);
46
// vout.general(vl, "%s \n", testname.c_str());
47
48
//vout.general(vl, "check precision = %d\n", precision);
49
vout
.
general
(
vl
,
"check precision = %2.1e\n"
, eps);
50
51
vout
.
general
(
vl
,
"result: %15.14le expected: %15.14le\n"
, result, expected);
52
53
double
diff;
54
if
(fabs(expected) > eps) {
55
diff = (result - expected) / expected;
56
}
else
{
57
diff = result - expected;
58
}
59
60
if
(fabs(diff) <= eps) {
61
vout
.
general
(
vl
,
"test result: correct! (^_^)\n"
);
62
verify_result = 0;
63
}
else
{
64
vout
.
general
(
vl
,
"test result: incorrect! (T_T)\n"
);
65
verify_result = 1;
66
}
67
vout
.
general
(
vl
,
"diff: expected - result = %15.14le\n"
, diff);
68
//vout.general(vl, "diff1: expected - result = %15.14le\n", diff);
69
//vout.general(vl, "diff2: exp(-diff) = %15.14le\n", exp(-diff));
70
vout
.
general
(
vl
,
"\n"
);
71
72
return
verify_result;
73
}
74
}
Test::verify
int verify(const double result, const double expected, double eps)
Definition:
test.cpp:27
bridgeIO.h
TestManager::Instance
static TestManager & Instance()
Definition:
testManager.cpp:40
TestManager::getCheckPrecision
int getCheckPrecision() const
Definition:
testManager.h:73
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition:
parameterCheck.cpp:18
test.h
CommonParameters::Vlevel
static Bridge::VerboseLevel Vlevel()
Definition:
commonParameters.h:122
Test
Definition:
test.cpp:26
commonParameters.h
Bridge::VerboseLevel
VerboseLevel
Definition:
bridgeIO.h:42
Test::default_precision
static const int default_precision
Definition:
test.h:32
testManager.h
Bridge::BridgeIO::general
void general(const char *format,...)
Definition:
bridgeIO.cpp:200
Bridge::vout
BridgeIO vout
Definition:
bridgeIO.cpp:512
CommonParameters::epsilon_criterion
static double epsilon_criterion()
Definition:
commonParameters.h:119
tests
src
test.cpp
Generated on Sat Feb 10 2024 14:20:01 for Bridge++ by
1.8.17