COIN-OR::LEMON - Graph Library

Changeset 82:bce6c8f93d10 in lemon-main for test


Ignore:
Timestamp:
03/15/08 23:39:41 (17 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Add basic logical maps and doc improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/maps_test.cc

    r80 r82  
    7979    map1 = constMap<A>(B());
    8080    map1.setAll(B());
    81    
     81
    8282    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
    8383    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
     
    9696    IdentityMap<A> map2 = map1;
    9797    map1 = identityMap<A>();
    98    
     98
    9999    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
    100100    check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14,
     
    152152    CompMap map1(DoubleMap(),ReadMap<B,A>());
    153153    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
    154    
     154
    155155    SparseMap<double, bool> m1(false); m1[3.14] = true;
    156156    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
     
    198198  {
    199199    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
    200    
     200
    201201    typedef RangeMap<double> RM;
    202202    typedef SparseMap<int, double> SM;
     
    211211          "Something is wrong with ForkMap");
    212212  }
    213  
     213
    214214  // Arithmetic maps:
    215215  // - AddMap, SubMap, MulMap, DivMap
     
    221221    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
    222222    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
    223    
     223
    224224    ConstMap<int, double> c1(1.0), c2(3.14);
    225225    IdentityMap<int> im;
     
    229229    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28, "Something is wrong with MulMap");
    230230    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57, "Something is wrong with DivMap");
    231    
     231
    232232    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
    233233    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
     
    253253          "Something is wrong with AbsMap");
    254254  }
    255  
    256   // Logical maps
    257   {
     255
     256  // Logical maps:
     257  // - TrueMap, FalseMap
     258  // - AndMap, OrMap
     259  // - NotMap, NotWriteMap
     260  // - EqualMap, LessMap
     261  {
     262    checkConcept<BoolMap, TrueMap<A> >();
     263    checkConcept<BoolMap, FalseMap<A> >();
     264    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
     265    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
    258266    checkConcept<BoolMap, NotMap<BoolMap> >();
    259267    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
    260    
     268    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
     269    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
     270
     271    TrueMap<int> tm;
     272    FalseMap<int> fm;
    261273    RangeMap<bool> rm(2);
    262274    rm[0] = true; rm[1] = false;
    263     check(!(notMap(rm)[0]) && notMap(rm)[1], "Something is wrong with NotMap");
    264     check(!(notWriteMap(rm)[0]) && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
     275    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
     276          "Something is wrong with AndMap");
     277    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1],
     278          "Something is wrong with OrMap");
     279    check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap");
     280    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
     281
     282    ConstMap<int, double> cm(2.0);
     283    IdentityMap<int> im;
     284    ConvertMap<IdentityMap<int>, double> id(im);
     285    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
     286          "Something is wrong with LessMap");
     287    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
     288          "Something is wrong with EqualMap");
    265289  }
    266290
Note: See TracChangeset for help on using the changeset viewer.