root/library/tests/datasource_test.cpp @ 603

Revision 603, 0.8 kB (checked in by smidl, 15 years ago)

datasources revisited...

Line 
1#include "../bdm/base/datasources.h"
2#include "mat_checks.h"
3#include "UnitTest++.h"
4
5using namespace bdm;
6
7TEST ( test_EpdfDS ) {
8        UIFile uif("epdfds.cfg");
9
10        shared_ptr<EpdfDS> ds=UI::build<EpdfDS>(uif, "ds");
11       
12        vec mean = zeros(2);
13        vec dt = zeros(2);
14        for (int i=0; i<100; i++){
15                ds->step();
16                ds->getdata(dt);
17                mean += dt;
18        }
19        CHECK_CLOSE_EX (  vec_2(1.0,2.0) ,mean/100, 1e-2);
20}
21
22TEST ( test_MpdfDS ) {
23        UIFile uif("mpdfds.cfg");
24
25        shared_ptr<MpdfDS> ds=UI::build<MpdfDS>(uif, "ds", UI::compulsory);
26       
27        vec dt = zeros(2);
28        vec ut="1.0";
29        ds->write(ut);
30        for (int i=0; i<100; i++){
31                ds->step();
32        }
33        ds->getdata(dt);
34        CHECK_CLOSE ( -0.2 , dt(0), 1e-4);
35
36        ut="2.0";
37        ds->write(ut);
38        for (int i=0; i<100; i++){
39                ds->step();
40        }
41        ds->getdata(dt);
42        CHECK_CLOSE ( -0.4 , dt(0), 1e-4);
43}
Note: See TracBrowser for help on using the browser.