1 | #define BDMLIB // not an ideal way to prevent double registration of UI factories... |
---|
2 | #include "stat/exp_family.h" |
---|
3 | #include "epdf_harness.h" |
---|
4 | #include "mat_checks.h" |
---|
5 | #include "test_util.h" |
---|
6 | #include "UnitTest++.h" |
---|
7 | |
---|
8 | using namespace bdm; |
---|
9 | |
---|
10 | const double epsilon = 0.00001; |
---|
11 | |
---|
12 | namespace UnitTest |
---|
13 | { |
---|
14 | |
---|
15 | inline void CheckClose(TestResults &results, const itpp::vec &expected, |
---|
16 | const itpp::vec &actual, double tolerance, |
---|
17 | TestDetails const& details) { |
---|
18 | if (!AreClose(expected, actual, tolerance)) { |
---|
19 | MemoryOutStream stream; |
---|
20 | stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual; |
---|
21 | |
---|
22 | results.OnTestFailure(details, stream.GetText()); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | inline void CheckClose(TestResults &results, const itpp::mat &expected, |
---|
27 | const itpp::mat &actual, double tolerance, |
---|
28 | TestDetails const& details) { |
---|
29 | if (!AreClose(expected, actual, tolerance)) { |
---|
30 | MemoryOutStream stream; |
---|
31 | stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual; |
---|
32 | |
---|
33 | results.OnTestFailure(details, stream.GetText()); |
---|
34 | } |
---|
35 | } |
---|
36 | |
---|
37 | } |
---|
38 | |
---|
39 | template<> |
---|
40 | const ParticularUI<enorm<ldmat> > &ParticularUI<enorm<ldmat> >::factory( |
---|
41 | ParticularUI<enorm<ldmat> >("enorm<ldmat>")); |
---|
42 | |
---|
43 | template<> |
---|
44 | const ParticularUI<enorm<fsqmat> > &ParticularUI<enorm<fsqmat> >::factory( |
---|
45 | ParticularUI<enorm<fsqmat> >("enorm<fsqmat>")); |
---|
46 | |
---|
47 | template<> |
---|
48 | const ParticularUI<enorm<chmat> > &ParticularUI<enorm<chmat> >::factory( |
---|
49 | ParticularUI<enorm<chmat> >("enorm<chmat>")); |
---|
50 | |
---|
51 | TEST(test_enorm) { |
---|
52 | RV::clear_all(); |
---|
53 | UIFile in("enorm.cfg"); |
---|
54 | Array<epdf_harness *> input; |
---|
55 | UI::get(input, in, "data"); |
---|
56 | int sz = input.size(); |
---|
57 | CHECK(sz > 0); |
---|
58 | for (int i = 0; i < sz; ++i) { |
---|
59 | input(i)->test(); |
---|
60 | } |
---|
61 | } |
---|