Changeset 480 for library

Show
Ignore:
Timestamp:
08/06/09 07:49:38 (15 years ago)
Author:
vbarta
Message:

fixed tests for new UI::get & UI::build

Location:
library/tests
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • library/tests/additive_generator.cpp

    r477 r480  
    77void additive_generator::from_setting ( const Setting &set ) { 
    88        int sz; 
    9         UI::get ( sz, set, "size" ); 
     9        UI::get ( sz, set, "size", UI::compulsory ); 
    1010 
    1111        mat a0 = randu ( sz, sz ); 
     
    1414        v2 = outer_product ( v, v ); 
    1515 
    16         if ( set.exists ( "lambda" ) ) { 
    17                 UI::get ( lambda, set, "lambda" ); 
    18         } 
     16        UI::get ( lambda, set, "lambda", UI::optional ); 
    1917} 
    2018 
  • library/tests/epdf_harness.cpp

    r477 r480  
    2020        UIFile in ( config_file_name ); 
    2121        Array<epdf_harness *> input; 
    22         UI::get ( input, in, "data" ); 
     22        UI::get ( input, in, "data", UI::compulsory ); 
    2323        int sz = input.size(); 
    2424        CHECK ( sz > 0 ); 
     
    3333        UI::get ( variance, set, "variance", UI::compulsory ); 
    3434 
     35        UI::get (support, set, "support", UI::optional ); 
     36        UI::get (nbins, set, "nbins", UI::optional ); 
     37        UI::get (nsamples, set, "nsamples", UI::optional ); 
     38        UI::get (R, set, "R", UI::optional ); 
    3539 
    36         UI::get ( support, set, "support" ); 
    37         UI::get ( nbins, set, "nbins" ); 
    38         UI::get ( nsamples, set, "nsamples" ); 
    39         UI::get ( R, set, "R" ); 
     40        mrv = UI::build<RV> (set, "marginal_rv", UI::optional ); 
    4041 
    41         RV* rv = UI::build<RV> ( set, "marginal_rv" ); 
    42         if ( rv ) 
    43                 mrv = shared_ptr<RV> ( rv ); 
    44  
    45         UI::get ( tolerance, set, "tolerance" ); 
     42        UI::get ( tolerance, set, "tolerance", UI::optional ); 
    4643} 
    4744 
  • library/tests/mpdf_harness.cpp

    r477 r480  
    1818        UIFile in ( config_file_name ); 
    1919        Array<mpdf_harness *> input; 
    20         UI::get ( input, in, "data" ); 
     20        UI::get ( input, in, "data", UI::compulsory ); 
    2121        int sz = input.size(); 
    2222        CHECK ( sz > 0 ); 
     
    3131        UI::get ( mean, set, "mean", UI::compulsory ); 
    3232 
    33  
    34         UI::get ( nsamples, set, "nsamples" ); 
    35         UI::get ( R, set, "R" ); 
    36         UI::get ( tolerance, set, "tolerance" ); 
     33        UI::get ( nsamples, set, "nsamples", UI::optional ); 
     34        UI::get ( R, set, "R", UI::optional ); 
     35        UI::get ( tolerance, set, "tolerance", UI::optional ); 
    3736} 
    3837 
     
    4544        mat er = ( smp * smp.T() ) / n - outer_product ( emu, emu ); 
    4645        CHECK_CLOSE_EX ( mean, emu, tolerance ); 
    47         CHECK_CLOSE_EX ( R, er, tolerance ); 
     46 
     47        if ( R.rows() > 0 ) { 
     48                CHECK_CLOSE_EX ( R, er, tolerance ); 
     49        } 
    4850} 
    4951 
  • library/tests/size_generator.cpp

    r477 r480  
    55using bdm::UI; 
    66 
    7 void size_generator::from_setting ( const Setting &set ) { 
    8         if ( set.exists ( "size" ) ) { 
    9                 UI::get ( sz, set, "size" ); 
    10         } 
    11  
    12         if ( set.exists ( "step" ) ) { 
    13                 UI::get ( step, set, "step" ); 
    14         } 
     7void size_generator::from_setting(const Setting &set) { 
     8        UI::get( sz, set, "size", UI::optional ); 
     9        UI::get( step, set, "step", UI::optional ); 
    1510} 
    1611 
  • library/tests/square_mat_point.cpp

    r477 r480  
    55 
    66void square_mat_point::from_setting ( const Setting &set ) { 
    7         UI::get ( matrix, set, "matrix" ); 
    8         UI::get ( vector, set, "vector" ); 
    9         UI::get ( scalar, set, "scalar" ); 
     7        UI::get ( matrix, set, "matrix", UI::compulsory ); 
     8        UI::get ( vector, set, "vector", UI::compulsory ); 
     9        UI::get ( scalar, set, "scalar", UI::compulsory ); 
    1010} 
    1111 
  • library/tests/square_mat_prep.cpp

    r477 r480  
    6565 
    6666                UIFile gspec ( generator_file_name ); 
    67                 auto_ptr<generator> gen ( UI::build<generator> ( gspec, "generator" ) ); 
     67                auto_ptr<generator> gen ( UI::build<generator> ( gspec, "generator", UI::compulsory ) ); 
    6868                for ( int i = 0; i < agenda_length; ++i ) { 
    6969                        mat m = gen->next(); 
  • library/tests/square_mat_stress.cpp

    r477 r480  
    176176        UIFile fag ( agenda_file_name ); 
    177177        Array<square_mat_point *> mag; 
    178         UI::get ( mag, fag, "agenda" ); 
     178        UI::get ( mag, fag, "agenda", UI::compulsory ); 
    179179        int sz = mag.size(); 
    180180        CHECK ( sz > 0 ); 
  • library/tests/test_user_info.cpp

    r471 r480  
    163163                Transport::from_setting ( set ); 
    164164 
    165                 UI::get ( electricLights, set, "electricLights" ); 
     165                int elights; 
     166                if ( UI::get ( elights, set, "electricLights", UI::optional ) ) { 
     167                    electricLights = !!elights; 
     168                } 
    166169 
    167170                UI::get ( matr, set, "matr" ); 
     
    189192TEST ( test_load ) { 
    190193        UIFile in ( "test_user_info_input.cfg" ); 
    191         auto_ptr<Transport> pepikovo ( UI::build<Transport> ( in, "pepikovo" ) ); 
     194        auto_ptr<Transport> pepikovo ( UI::build<Transport> ( in, "pepikovo", UI::compulsory ) ); 
    192195        CHECK_EQUAL ( string ( "A car made in 1998 by audi, having 25000 kilometers on the clock.The names of passengers are as follows: Karlos Novak -1_CygWin_Matlab_Aimsun Karlosik Novacek " ), pepikovo->to_string() ); 
    193196 
    194         auto_ptr<Transport> jardovo ( UI::build<Transport> ( in, "jardovo" ) ); 
     197        auto_ptr<Transport> jardovo ( UI::build<Transport> ( in, "jardovo", UI::compulsory ) ); 
    195198        CHECK_EQUAL ( string ( "A car made in 1992 by liaz, having 1555000 kilometers on the clock." ), jardovo->to_string() ); 
    196199 
    197         auto_ptr<Transport> ondrejovo ( UI::build<Transport> ( in, "ondrejovo" ) ); 
     200        auto_ptr<Transport> ondrejovo ( UI::build<Transport> ( in, "ondrejovo", UI::compulsory ) ); 
    198201        CHECK_EQUAL ( string ( "a bike made in 1996 by author with electric lights included" ), ondrejovo->to_string() ); 
    199202 
    200         auto_ptr<Transport> elisky ( UI::build<Transport> ( in, "elisky" ) ); 
     203        auto_ptr<Transport> elisky ( UI::build<Transport> ( in, "elisky", UI::compulsory ) ); 
    201204        CHECK_EQUAL ( string ( "A car made in 1992 by liaz, having 1555000 kilometers on the clock." ), elisky->to_string() ); 
    202205 
    203         auto_ptr<Transport> kati ( UI::build<Transport> ( in, "kati" ) ); 
     206        auto_ptr<Transport> kati ( UI::build<Transport> ( in, "kati", UI::compulsory ) ); 
    204207        CHECK_EQUAL ( string ( "A car made in 1980 by vecernicek, having 250000 kilometers on the clock." ), kati->to_string() ); 
    205208} 
     
    207210TEST ( test_save ) { 
    208211        UIFile in ( "test_user_info_input.cfg" ); 
    209         auto_ptr<Transport> pepikovo ( UI::build<Transport> ( in, "pepikovo" ) ); 
     212        auto_ptr<Transport> pepikovo ( UI::build<Transport> ( in, "pepikovo", UI::compulsory ) ); 
    210213 
    211214        Car audi ( 1968, "zyl", 200 ); 
  • library/tests/test_user_info_input.cfg

    r386 r480  
    2525  year = 1996; 
    2626  manufacturer = "author"; 
    27   electricLights = true; 
     27  electricLights = 1; 
    2828  matr = ( 2, 2, [ 1.0, 0.0, 0.0, 1.0 ] ); 
    2929};