Show
Ignore:
Timestamp:
06/09/10 14:00:40 (14 years ago)
Author:
mido
Message:

astyle applied all over the library

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/testsuite/rv_test.cpp

    r1008 r1064  
    77 
    88TEST ( rv_test ) { 
    9         RV::clear_all(); 
     9    RV::clear_all(); 
    1010 
    11         RV a = RV ( "{a_in_test_rv }", "3" ); 
    12         CHECK ( a.equal ( a ) ); 
    13         CHECK_EQUAL ( 1, a.length() ); 
    14         CHECK_EQUAL ( 3, a.size ( 0 ) ); 
    15         CHECK_EQUAL ( std::string ( "a_in_test_rv" ), a.name ( 0 ) ); 
     11    RV a = RV ( "{a_in_test_rv }", "3" ); 
     12    CHECK ( a.equal ( a ) ); 
     13    CHECK_EQUAL ( 1, a.length() ); 
     14    CHECK_EQUAL ( 3, a.size ( 0 ) ); 
     15    CHECK_EQUAL ( std::string ( "a_in_test_rv" ), a.name ( 0 ) ); 
    1616 
    17         RV b = RV ( "{b_in_test_rv }", "2" ); 
    18         CHECK ( !b.equal ( a ) ); 
    19         CHECK_EQUAL ( 0, b.mint() ); 
     17    RV b = RV ( "{b_in_test_rv }", "2" ); 
     18    CHECK ( !b.equal ( a ) ); 
     19    CHECK_EQUAL ( 0, b.mint() ); 
    2020 
    21         RV c = RV ( "{c_in_test_rv }" ); 
    22         CHECK_EQUAL ( 1, c.length() ); 
    23         CHECK_EQUAL ( 1, c.size ( 0 ) ); 
     21    RV c = RV ( "{c_in_test_rv }" ); 
     22    CHECK_EQUAL ( 1, c.length() ); 
     23    CHECK_EQUAL ( 1, c.size ( 0 ) ); 
    2424 
    25         RV trv = RV ( "{e_in_test_rv f_in_test_rv }", "1 2", "3 4" ); 
    26         CHECK_EQUAL ( 2, trv.length() ); 
    27         CHECK_EQUAL ( 3, trv.mint() ); 
     25    RV trv = RV ( "{e_in_test_rv f_in_test_rv }", "1 2", "3 4" ); 
     26    CHECK_EQUAL ( 2, trv.length() ); 
     27    CHECK_EQUAL ( 3, trv.mint() ); 
    2828 
    29         // add a and b 
    30         RV ab = a; 
    31         bool added = ab.add ( b ); 
    32         CHECK ( added ); 
    33         CHECK_EQUAL ( 2, ab.length() ); 
    34         CHECK_EQUAL ( 3, ab.size ( 0 ) ); 
    35         CHECK_EQUAL ( std::string ( "a_in_test_rv" ), ab.name ( 0 ) ); 
    36         CHECK_EQUAL ( 2, ab.size ( 1 ) ); 
    37         CHECK_EQUAL ( std::string ( "b_in_test_rv" ), ab.name ( 1 ) ); 
     29    // add a and b 
     30    RV ab = a; 
     31    bool added = ab.add ( b ); 
     32    CHECK ( added ); 
     33    CHECK_EQUAL ( 2, ab.length() ); 
     34    CHECK_EQUAL ( 3, ab.size ( 0 ) ); 
     35    CHECK_EQUAL ( std::string ( "a_in_test_rv" ), ab.name ( 0 ) ); 
     36    CHECK_EQUAL ( 2, ab.size ( 1 ) ); 
     37    CHECK_EQUAL ( std::string ( "b_in_test_rv" ), ab.name ( 1 ) ); 
    3838 
    39         std::stringstream abss; 
    40         abss << ab; 
    41         CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; b_in_test_rv(2)_{0}; ]" ), abss.str() ); 
     39    std::stringstream abss; 
     40    abss << ab; 
     41    CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; b_in_test_rv(2)_{0}; ]" ), abss.str() ); 
    4242 
    43         // concat a, b and c 
    44         RV abc = concat ( ab, c ); 
    45         CHECK_EQUAL ( 3, abc.length() ); 
    46         std::stringstream abcss; 
    47         abcss << abc; 
    48         CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; b_in_test_rv(2)_{0}; c_in_test_rv(1)_{0}; ]" ), abcss.str() ); 
     43    // concat a, b and c 
     44    RV abc = concat ( ab, c ); 
     45    CHECK_EQUAL ( 3, abc.length() ); 
     46    std::stringstream abcss; 
     47    abcss << abc; 
     48    CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; b_in_test_rv(2)_{0}; c_in_test_rv(1)_{0}; ]" ), abcss.str() ); 
    4949 
    50         // structure of a, b, c 
    51         str s = abc.tostr(); 
    52         int exp_ids[] = { 1, 1, 1, 2, 2, 3 }; 
    53         int exp_sz = sizeof ( exp_ids ) / sizeof ( exp_ids[0] ); 
    54         CHECK_EQUAL ( exp_sz, s.ids.size() ); 
    55         CHECK_EQUAL ( exp_sz, s.times.size() ); 
    56         for ( int i = 0; i < exp_sz; ++i ) { 
    57                 CHECK_EQUAL ( exp_ids[i], s.ids ( i ) ); 
    58                 CHECK_EQUAL ( 0, s.times ( i ) ); 
    59         } 
     50    // structure of a, b, c 
     51    str s = abc.tostr(); 
     52    int exp_ids[] = { 1, 1, 1, 2, 2, 3 }; 
     53    int exp_sz = sizeof ( exp_ids ) / sizeof ( exp_ids[0] ); 
     54    CHECK_EQUAL ( exp_sz, s.ids.size() ); 
     55    CHECK_EQUAL ( exp_sz, s.times.size() ); 
     56    for ( int i = 0; i < exp_sz; ++i ) { 
     57        CHECK_EQUAL ( exp_ids[i], s.ids ( i ) ); 
     58        CHECK_EQUAL ( 0, s.times ( i ) ); 
     59    } 
    6060 
    61         RV slice = abc ( 1, 2 ); 
    62         CHECK_EQUAL ( 1, slice.length() ); 
    63         CHECK_EQUAL ( 3, slice.size ( 0 ) ); 
    64         CHECK_EQUAL ( std::string ( "a_in_test_rv" ), slice.name ( 0 ) ); 
     61    RV slice = abc ( 1, 2 ); 
     62    CHECK_EQUAL ( 1, slice.length() ); 
     63    CHECK_EQUAL ( 3, slice.size ( 0 ) ); 
     64    CHECK_EQUAL ( std::string ( "a_in_test_rv" ), slice.name ( 0 ) ); 
    6565 
    66         // find a in abc 
    67         ivec f = a.findself ( abc ); 
    68         CHECK_EQUAL ( 1, f.length() ); 
    69         CHECK_EQUAL ( 0, f ( 0 ) ); 
     66    // find a in abc 
     67    ivec f = a.findself ( abc ); 
     68    CHECK_EQUAL ( 1, f.length() ); 
     69    CHECK_EQUAL ( 0, f ( 0 ) ); 
    7070 
    71         // find abc in a 
    72         f = abc.findself ( a ); 
    73         int exp_indices[] = { 0, -1, -1 }; 
    74         CHECK_EQUAL ( 3, f.length() ); 
    75         for ( unsigned i = 0; 
    76                 i < sizeof ( exp_indices ) / sizeof ( exp_indices[0] ); 
    77                 ++i ) { 
    78                 CHECK_EQUAL ( exp_indices[i], f ( i ) ); 
    79         } 
     71    // find abc in a 
     72    f = abc.findself ( a ); 
     73    int exp_indices[] = { 0, -1, -1 }; 
     74    CHECK_EQUAL ( 3, f.length() ); 
     75    for ( unsigned i = 0; 
     76            i < sizeof ( exp_indices ) / sizeof ( exp_indices[0] ); 
     77            ++i ) { 
     78        CHECK_EQUAL ( exp_indices[i], f ( i ) ); 
     79    } 
    8080 
    81         // subtract b from abc 
    82         RV ac = abc.subt ( b ); 
    83         std::stringstream acss; 
    84         acss << ac; 
    85         CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; c_in_test_rv(1)_{0}; ]" ), acss.str() ); 
     81    // subtract b from abc 
     82    RV ac = abc.subt ( b ); 
     83    std::stringstream acss; 
     84    acss << ac; 
     85    CHECK_EQUAL ( std::string ( "[a_in_test_rv(3)_{0}; c_in_test_rv(1)_{0}; ]" ), acss.str() ); 
    8686 
    87         // data index of ac in abc 
    88         ivec di = ac.dataind ( abc ); 
    89         int exp_di[] = { 0, 1, 2, 5 }; 
    90         exp_sz = sizeof ( exp_di ) / sizeof ( exp_di[0] ); 
    91         CHECK_EQUAL ( exp_sz, di.size() ); 
    92         for ( int i = 0; i < exp_sz; ++i ) { 
    93                 CHECK_EQUAL ( exp_di[i], di ( i ) ); 
    94         } 
     87    // data index of ac in abc 
     88    ivec di = ac.dataind ( abc ); 
     89    int exp_di[] = { 0, 1, 2, 5 }; 
     90    exp_sz = sizeof ( exp_di ) / sizeof ( exp_di[0] ); 
     91    CHECK_EQUAL ( exp_sz, di.size() ); 
     92    for ( int i = 0; i < exp_sz; ++i ) { 
     93        CHECK_EQUAL ( exp_di[i], di ( i ) ); 
     94    } 
    9595 
    96         // subselect 
    97         RV bc = abc ( ivec ( "1 2" ) ); 
    98         std::stringstream bcss; 
    99         bcss << bc; 
    100         CHECK_EQUAL ( std::string ( "[b_in_test_rv(2)_{0}; c_in_test_rv(1)_{0}; ]" ), bcss.str() ); 
     96    // subselect 
     97    RV bc = abc ( ivec ( "1 2" ) ); 
     98    std::stringstream bcss; 
     99    bcss << bc; 
     100    CHECK_EQUAL ( std::string ( "[b_in_test_rv(2)_{0}; c_in_test_rv(1)_{0}; ]" ), bcss.str() ); 
    101101 
    102102#if 0 
    103         // actually doesn't select, just reorders the variables - 
    104         // wonder if that's correct... 
    105         bc = abc ( 1, 2 ); 
    106         bcss << bc; 
    107         CHECK_EQUAL ( std::string ( "2(2)=b_in_test_rv_{0}; 3(1)=c_in_test_rv_{0}; " ), bcss.str() ); 
     103    // actually doesn't select, just reorders the variables - 
     104    // wonder if that's correct... 
     105    bc = abc ( 1, 2 ); 
     106    bcss << bc; 
     107    CHECK_EQUAL ( std::string ( "2(2)=b_in_test_rv_{0}; 3(1)=c_in_test_rv_{0}; " ), bcss.str() ); 
    108108#endif 
    109109 
    110         // Copy indices between ba and ab 
    111         RV ba = b; 
    112         ba.add ( a ); 
     110    // Copy indices between ba and ab 
     111    RV ba = b; 
     112    ba.add ( a ); 
    113113 
    114         ivec ai; 
    115         ivec bi; 
    116         ba.dataind ( ac, ai, bi ); 
     114    ivec ai; 
     115    ivec bi; 
     116    ba.dataind ( ac, ai, bi ); 
    117117 
    118         int exp_ai[] = { 2, 3, 4 }; 
    119         exp_sz = sizeof ( exp_ai ) / sizeof ( exp_ai[0] ); 
    120         CHECK_EQUAL ( exp_sz, ai.size() ); 
    121         for ( unsigned i = 0; 
    122                 i < sizeof ( exp_ai ) / sizeof ( exp_ai[0] ); 
    123                 ++i ) { 
    124                 CHECK_EQUAL ( exp_ai[i], ai ( i ) ); 
    125         } 
     118    int exp_ai[] = { 2, 3, 4 }; 
     119    exp_sz = sizeof ( exp_ai ) / sizeof ( exp_ai[0] ); 
     120    CHECK_EQUAL ( exp_sz, ai.size() ); 
     121    for ( unsigned i = 0; 
     122            i < sizeof ( exp_ai ) / sizeof ( exp_ai[0] ); 
     123            ++i ) { 
     124        CHECK_EQUAL ( exp_ai[i], ai ( i ) ); 
     125    } 
    126126 
    127         int exp_bi[] = { 0, 1, 2 }; 
    128         exp_sz = sizeof ( exp_bi ) / sizeof ( exp_bi[0] ); 
    129         CHECK_EQUAL ( exp_sz, bi.size() ); 
    130         for ( unsigned i = 0; 
    131                 i < sizeof ( exp_bi ) / sizeof ( exp_bi[0] ); 
    132                 ++i ) { 
    133                 CHECK_EQUAL ( exp_bi[i], bi ( i ) ); 
    134         } 
     127    int exp_bi[] = { 0, 1, 2 }; 
     128    exp_sz = sizeof ( exp_bi ) / sizeof ( exp_bi[0] ); 
     129    CHECK_EQUAL ( exp_sz, bi.size() ); 
     130    for ( unsigned i = 0; 
     131            i < sizeof ( exp_bi ) / sizeof ( exp_bi[0] ); 
     132            ++i ) { 
     133        CHECK_EQUAL ( exp_bi[i], bi ( i ) ); 
     134    } 
    135135 
    136         // check uniqueness 
    137         RV join = a; 
    138         join.add ( b ); 
    139         RV tmp = a; 
    140         tmp.t_plus ( 1 ); 
    141         join.add ( tmp ); 
    142         tmp = b; 
    143         tmp.t_plus ( -1 ); 
    144         join.add ( tmp ); 
     136    // check uniqueness 
     137    RV join = a; 
     138    join.add ( b ); 
     139    RV tmp = a; 
     140    tmp.t_plus ( 1 ); 
     141    join.add ( tmp ); 
     142    tmp = b; 
     143    tmp.t_plus ( -1 ); 
     144    join.add ( tmp ); 
    145145 
    146         CHECK_EQUAL ( unique ( join._ids() ), vec_2 ( a.id ( 0 ), b.id ( 0 ) ) ); // find only ids of a and b 
    147         CHECK_EQUAL ( unique_complement ( join._ids(), vec_1 ( a.id ( 0 ) ) ), vec_1 ( b.id ( 0 ) ) ); // complemnet of a in previous is b 
     146    CHECK_EQUAL ( unique ( join._ids() ), vec_2 ( a.id ( 0 ), b.id ( 0 ) ) ); // find only ids of a and b 
     147    CHECK_EQUAL ( unique_complement ( join._ids(), vec_1 ( a.id ( 0 ) ) ), vec_1 ( b.id ( 0 ) ) ); // complemnet of a in previous is b 
    148148 
    149         //test if unique names work 
    150         RV uniq1 ( "y", 1 ); 
    151         RV uniq2 ( "y", 1 ); 
     149    //test if unique names work 
     150    RV uniq1 ( "y", 1 ); 
     151    RV uniq2 ( "y", 1 ); 
    152152 
    153         CHECK_EQUAL ( uniq1.id ( 0 ), uniq2.id ( 0 ) ); 
     153    CHECK_EQUAL ( uniq1.id ( 0 ), uniq2.id ( 0 ) ); 
    154154 
    155         // check scalarname 
    156         CHECK_EQUAL ( "a_in_test_rv_2", abc.scalarname ( 2 ) ); 
    157         CHECK_EQUAL ( "b_in_test_rv_0", abc.scalarname ( 3 ) ); 
     155    // check scalarname 
     156    CHECK_EQUAL ( "a_in_test_rv_2", abc.scalarname ( 2 ) ); 
     157    CHECK_EQUAL ( "b_in_test_rv_0", abc.scalarname ( 3 ) ); 
    158158}