root/library/tests/egiw_harness.cpp @ 439

Revision 439, 1.4 kB (checked in by vbarta, 15 years ago)

split epdf_harness to common base & testing specific to a particular class

Line 
1#include "egiw_harness.h"
2#include "stat/exp_family.h"
3#include "mat_checks.h"
4#include "test_util.h"
5#include "UnitTest++.h"
6
7const double epsilon = 0.00001;
8
9namespace UnitTest
10{
11
12inline void CheckClose(TestResults &results, const itpp::vec &expected,
13                       const itpp::vec &actual, double tolerance,
14                       TestDetails const &details) {
15    if (!AreClose(expected, actual, tolerance)) { 
16        MemoryOutStream stream;
17        stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual;
18
19        results.OnTestFailure(details, stream.GetText());
20    }
21}
22
23inline void CheckClose(TestResults &results, const itpp::mat &expected,
24                       const itpp::mat &actual, double tolerance,
25                       TestDetails const &details) {
26    if (!AreClose(expected, actual, tolerance)) { 
27        MemoryOutStream stream;
28        stream << "Expected " << expected << " +/- " << tolerance << " but was " << actual;
29
30        results.OnTestFailure(details, stream.GetText());
31    }
32}
33
34}
35
36namespace bdm {
37
38template<>
39const ParticularUI<egiw_harness> &ParticularUI<egiw_harness>::factory(
40    ParticularUI<egiw_harness>("egiw_harness"));
41
42void egiw_harness::from_setting(const Setting &set) {
43    epdf_harness::from_setting(set);
44    UI::get(lognc, set, "lognc");
45}
46
47void egiw_harness::test()
48{
49    epdf_harness::test();
50
51    egiw *wide = dynamic_cast<egiw *>(get_epdf());
52    CHECK(wide);
53
54    CHECK_CLOSE(lognc, wide->lognc(), epsilon);
55}
56
57}
Note: See TracBrowser for help on using the browser.