[428] | 1 | #define BDMLIB // not an ideal way to prevent double registration of UI factories... |
---|
[386] | 2 | #include "stat/exp_family.h" |
---|
[443] | 3 | #include "epdf_harness.h" |
---|
[428] | 4 | #include "mat_checks.h" |
---|
[436] | 5 | #include "test_util.h" |
---|
[428] | 6 | #include "UnitTest++.h" |
---|
| 7 | |
---|
[254] | 8 | using namespace bdm; |
---|
[179] | 9 | |
---|
[428] | 10 | const double epsilon = 0.00001; |
---|
[179] | 11 | |
---|
[428] | 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 | |
---|
[443] | 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 | |
---|
[428] | 47 | TEST(test_enorm) { |
---|
[443] | 48 | RV::clear_all(); |
---|
| 49 | UIFile in("enorm.cfg"); |
---|
| 50 | Array<epdf_harness *> input; |
---|
| 51 | UI::get(input, in, "data"); |
---|
| 52 | int sz = input.size(); |
---|
| 53 | CHECK(sz > 0); |
---|
| 54 | for (int i = 0; i < sz; ++i) { |
---|
| 55 | input(i)->test(); |
---|
| 56 | } |
---|
| 57 | } |
---|