-
Notifications
You must be signed in to change notification settings - Fork 3
/
Tester.cpp
76 lines (66 loc) · 1.46 KB
/
Tester.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "Tester.h"
#include <string>
Tester::Tester(std::stringstream& ss): ss(ss)
{
// node();
// eig();
// cluster();
// concat();
// solveClusters();
// calAlpha();
// OutputDebugstd::string(ss.str().c_str());
}
Tester::~Tester()
{
}
bool Tester::it(const std::string des, const MatrixXd& expect, const MatrixXd& given, double esp) const
{
ss << des << ": ";
MatrixXd diff = expect - given;
if (diff.squaredNorm() < esp)
{
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpected:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}
bool Tester::it(const std::string des, const VectorXd& expect, const VectorXd& given, double esp) const
{
ss << des << ": ";
VectorXd diff = expect - given;
if (diff.squaredNorm() < esp)
{
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpected:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}
auto Tester::it(const std::string des, double expect, double given, double esp) -> bool
{
ss << des << ": ";
double diff = expect - given;
if (diff < esp)
{
ss << "OK" << std::endl;
return true;
}
ss << "Error\nExpect:" << std::endl;
ss << expect << std::endl;
ss << "Found:" << std::endl;
ss << given << std::endl;
return false;
}
bool Tester::it(const std::string des, bool flag) const
{
ss << des << ": ";
ss << (flag ? "OK" : "Error") << std::endl;
return flag;
}