Revision 441, 1.1 kB
(checked in by vbarta, 15 years ago)
|
added configurable tests for egamma
|
Rev | Line | |
---|
[441] | 1 | #define BDMLIB // not an ideal way to prevent double registration of UI factories... |
---|
| 2 | #include "base/bdmbase.h" |
---|
| 3 | #include "base/user_info.h" |
---|
| 4 | #include "stat/exp_family.h" |
---|
| 5 | #include "itpp_ext.h" |
---|
| 6 | #include "epdf_harness.h" |
---|
| 7 | #include "egiw_harness.h" |
---|
| 8 | #include "mat_checks.h" |
---|
| 9 | #include "UnitTest++.h" |
---|
| 10 | |
---|
| 11 | const double epsilon = 0.00001; |
---|
| 12 | |
---|
| 13 | namespace UnitTest |
---|
| 14 | { |
---|
| 15 | |
---|
| 16 | inline void CheckClose(TestResults &results, const itpp::vec &expected, |
---|
| 17 | const itpp::vec &actual, double tolerance, |
---|
| 18 | TestDetails const &details) { |
---|
| 19 | if (!AreClose(expected, actual, tolerance)) { |
---|
| 20 | MemoryOutStream stream; |
---|
| 21 | stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual; |
---|
| 22 | |
---|
| 23 | results.OnTestFailure(details, stream.GetText()); |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | using namespace bdm; |
---|
| 30 | |
---|
| 31 | template<> |
---|
| 32 | const ParticularUI<egamma> &ParticularUI<egamma>::factory( |
---|
| 33 | ParticularUI<egamma>("egamma")); |
---|
| 34 | |
---|
| 35 | TEST(test_egamma) { |
---|
| 36 | RV::clear_all(); |
---|
| 37 | UIFile in("egamma.cfg"); |
---|
| 38 | Array<epdf_harness *> input; |
---|
| 39 | UI::get(input, in, "data"); |
---|
| 40 | int sz = input.size(); |
---|
| 41 | CHECK(sz > 0); |
---|
| 42 | for (int i = 0; i < sz; ++i) { |
---|
| 43 | input(i)->test(); |
---|
| 44 | } |
---|
| 45 | } |
---|