test/maps_test.cc
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 09 Aug 2013 11:07:27 +0200
changeset 1090 70b199792735
parent 997 761fe0846f49
child 1084 8b2d4e5d96e4
permissions -rw-r--r--
Clarification in biNodeConnected() doc (#439)
alpar@209
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@25
     2
 *
alpar@209
     3
 * This file is a part of LEMON, a generic C++ optimization library.
alpar@25
     4
 *
alpar@440
     5
 * Copyright (C) 2003-2009
alpar@25
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@25
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@25
     8
 *
alpar@25
     9
 * Permission to use, modify and distribute this software is granted
alpar@25
    10
 * provided that this copyright notice appears in all copies. For
alpar@25
    11
 * precise terms see the accompanying LICENSE file.
alpar@25
    12
 *
alpar@25
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@25
    14
 * express or implied, and with no claim as to its suitability for any
alpar@25
    15
 * purpose.
alpar@25
    16
 *
alpar@25
    17
 */
alpar@25
    18
alpar@25
    19
#include <deque>
alpar@25
    20
#include <set>
alpar@25
    21
alpar@25
    22
#include <lemon/concept_check.h>
alpar@25
    23
#include <lemon/concepts/maps.h>
alpar@25
    24
#include <lemon/maps.h>
kpeter@684
    25
#include <lemon/list_graph.h>
alpar@25
    26
alpar@25
    27
#include "test_tools.h"
alpar@25
    28
alpar@25
    29
using namespace lemon;
alpar@25
    30
using namespace lemon::concepts;
alpar@25
    31
alpar@25
    32
struct A {};
alpar@25
    33
inline bool operator<(A, A) { return true; }
alpar@25
    34
struct B {};
alpar@25
    35
kpeter@94
    36
class C {
kpeter@94
    37
  int x;
kpeter@94
    38
public:
kpeter@94
    39
  C(int _x) : x(_x) {}
kpeter@94
    40
};
kpeter@94
    41
alpar@25
    42
class F {
alpar@25
    43
public:
alpar@25
    44
  typedef A argument_type;
alpar@25
    45
  typedef B result_type;
alpar@25
    46
kpeter@80
    47
  B operator()(const A&) const { return B(); }
kpeter@80
    48
private:
kpeter@80
    49
  F& operator=(const F&);
alpar@25
    50
};
alpar@25
    51
kpeter@80
    52
int func(A) { return 3; }
alpar@25
    53
kpeter@80
    54
int binc(int a, B) { return a+1; }
alpar@25
    55
kpeter@80
    56
typedef ReadMap<A, double> DoubleMap;
kpeter@80
    57
typedef ReadWriteMap<A, double> DoubleWriteMap;
kpeter@80
    58
typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
alpar@25
    59
kpeter@80
    60
typedef ReadMap<A, bool> BoolMap;
alpar@25
    61
typedef ReadWriteMap<A, bool> BoolWriteMap;
kpeter@80
    62
typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
alpar@25
    63
alpar@25
    64
int main()
kpeter@80
    65
{
kpeter@80
    66
  // Map concepts
alpar@25
    67
  checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
kpeter@94
    68
  checkConcept<ReadMap<A,C>, ReadMap<A,C> >();
alpar@25
    69
  checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
kpeter@94
    70
  checkConcept<WriteMap<A,C>, WriteMap<A,C> >();
alpar@25
    71
  checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
kpeter@94
    72
  checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >();
alpar@25
    73
  checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
kpeter@94
    74
  checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >();
alpar@25
    75
kpeter@80
    76
  // NullMap
kpeter@80
    77
  {
kpeter@80
    78
    checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
kpeter@80
    79
    NullMap<A,B> map1;
kpeter@80
    80
    NullMap<A,B> map2 = map1;
alpar@1083
    81
    ::lemon::ignore_unused_variable_warning(map2);
kpeter@80
    82
    map1 = nullMap<A,B>();
kpeter@80
    83
  }
kpeter@80
    84
kpeter@80
    85
  // ConstMap
kpeter@80
    86
  {
kpeter@80
    87
    checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
kpeter@123
    88
    checkConcept<ReadWriteMap<A,C>, ConstMap<A,C> >();
kpeter@80
    89
    ConstMap<A,B> map1;
deba@136
    90
    ConstMap<A,B> map2 = B();
kpeter@80
    91
    ConstMap<A,B> map3 = map1;
alpar@1083
    92
    ::lemon::ignore_unused_variable_warning(map2,map3);
alpar@997
    93
kpeter@80
    94
    map1 = constMap<A>(B());
kpeter@123
    95
    map1 = constMap<A,B>();
kpeter@80
    96
    map1.setAll(B());
kpeter@123
    97
    ConstMap<A,C> map4(C(1));
kpeter@123
    98
    ConstMap<A,C> map5 = map4;
alpar@1083
    99
    ::lemon::ignore_unused_variable_warning(map5);
alpar@997
   100
kpeter@123
   101
    map4 = constMap<A>(C(2));
kpeter@123
   102
    map4.setAll(C(3));
kpeter@82
   103
kpeter@80
   104
    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
kpeter@80
   105
    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
kpeter@80
   106
kpeter@80
   107
    checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
kpeter@123
   108
    ConstMap<A,Const<int,10> > map6;
kpeter@123
   109
    ConstMap<A,Const<int,10> > map7 = map6;
kpeter@123
   110
    map6 = constMap<A,int,10>();
kpeter@123
   111
    map7 = constMap<A,Const<int,10> >();
alpar@210
   112
    check(map6[A()] == 10 && map7[A()] == 10,
alpar@210
   113
          "Something is wrong with ConstMap");
kpeter@80
   114
  }
kpeter@80
   115
kpeter@80
   116
  // IdentityMap
kpeter@80
   117
  {
kpeter@80
   118
    checkConcept<ReadMap<A,A>, IdentityMap<A> >();
kpeter@80
   119
    IdentityMap<A> map1;
kpeter@80
   120
    IdentityMap<A> map2 = map1;
alpar@1083
   121
    ::lemon::ignore_unused_variable_warning(map2);
alpar@997
   122
kpeter@80
   123
    map1 = identityMap<A>();
kpeter@82
   124
kpeter@80
   125
    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
alpar@210
   126
    check(identityMap<double>()[1.0] == 1.0 &&
alpar@210
   127
          identityMap<double>()[3.14] == 3.14,
kpeter@80
   128
          "Something is wrong with IdentityMap");
kpeter@80
   129
  }
kpeter@80
   130
kpeter@80
   131
  // RangeMap
kpeter@80
   132
  {
kpeter@80
   133
    checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >();
kpeter@80
   134
    RangeMap<B> map1;
kpeter@80
   135
    RangeMap<B> map2(10);
kpeter@80
   136
    RangeMap<B> map3(10,B());
kpeter@80
   137
    RangeMap<B> map4 = map1;
kpeter@80
   138
    RangeMap<B> map5 = rangeMap<B>();
kpeter@80
   139
    RangeMap<B> map6 = rangeMap<B>(10);
kpeter@80
   140
    RangeMap<B> map7 = rangeMap(10,B());
kpeter@80
   141
kpeter@80
   142
    checkConcept< ReferenceMap<int, double, double&, const double&>,
kpeter@80
   143
                  RangeMap<double> >();
kpeter@80
   144
    std::vector<double> v(10, 0);
kpeter@80
   145
    v[5] = 100;
kpeter@80
   146
    RangeMap<double> map8(v);
kpeter@80
   147
    RangeMap<double> map9 = rangeMap(v);
kpeter@80
   148
    check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100,
kpeter@80
   149
          "Something is wrong with RangeMap");
kpeter@80
   150
  }
kpeter@80
   151
kpeter@80
   152
  // SparseMap
kpeter@80
   153
  {
kpeter@80
   154
    checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >();
kpeter@80
   155
    SparseMap<A,B> map1;
deba@136
   156
    SparseMap<A,B> map2 = B();
kpeter@80
   157
    SparseMap<A,B> map3 = sparseMap<A,B>();
kpeter@80
   158
    SparseMap<A,B> map4 = sparseMap<A>(B());
kpeter@80
   159
kpeter@80
   160
    checkConcept< ReferenceMap<double, int, int&, const int&>,
kpeter@80
   161
                  SparseMap<double, int> >();
kpeter@80
   162
    std::map<double, int> m;
kpeter@80
   163
    SparseMap<double, int> map5(m);
kpeter@80
   164
    SparseMap<double, int> map6(m,10);
kpeter@80
   165
    SparseMap<double, int> map7 = sparseMap(m);
kpeter@80
   166
    SparseMap<double, int> map8 = sparseMap(m,10);
kpeter@80
   167
alpar@210
   168
    check(map5[1.0] == 0 && map5[3.14] == 0 &&
alpar@210
   169
          map6[1.0] == 10 && map6[3.14] == 10,
kpeter@80
   170
          "Something is wrong with SparseMap");
kpeter@80
   171
    map5[1.0] = map6[3.14] = 100;
alpar@210
   172
    check(map5[1.0] == 100 && map5[3.14] == 0 &&
alpar@210
   173
          map6[1.0] == 10 && map6[3.14] == 100,
kpeter@80
   174
          "Something is wrong with SparseMap");
kpeter@80
   175
  }
kpeter@80
   176
kpeter@80
   177
  // ComposeMap
kpeter@80
   178
  {
kpeter@80
   179
    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
kpeter@80
   180
    checkConcept<ReadMap<B,double>, CompMap>();
alpar@477
   181
    CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>());
alpar@1083
   182
    ::lemon::ignore_unused_variable_warning(map1);
kpeter@80
   183
    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
alpar@1083
   184
    ::lemon::ignore_unused_variable_warning(map2);
kpeter@82
   185
kpeter@80
   186
    SparseMap<double, bool> m1(false); m1[3.14] = true;
kpeter@80
   187
    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
alpar@210
   188
    check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1],
alpar@210
   189
          "Something is wrong with ComposeMap")
kpeter@80
   190
  }
kpeter@80
   191
kpeter@80
   192
  // CombineMap
kpeter@80
   193
  {
kpeter@80
   194
    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
kpeter@80
   195
    checkConcept<ReadMap<A,double>, CombMap>();
alpar@477
   196
    CombMap map1 = CombMap(DoubleMap(), DoubleMap());
alpar@1083
   197
    ::lemon::ignore_unused_variable_warning(map1);
kpeter@80
   198
    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
alpar@1083
   199
    ::lemon::ignore_unused_variable_warning(map2);
kpeter@80
   200
kpeter@80
   201
    check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
kpeter@80
   202
          "Something is wrong with CombineMap");
kpeter@80
   203
  }
kpeter@80
   204
kpeter@80
   205
  // FunctorToMap, MapToFunctor
kpeter@80
   206
  {
kpeter@80
   207
    checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
kpeter@80
   208
    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
kpeter@80
   209
    FunctorToMap<F> map1;
alpar@477
   210
    FunctorToMap<F> map2 = FunctorToMap<F>(F());
alpar@1083
   211
    ::lemon::ignore_unused_variable_warning(map2);
alpar@997
   212
kpeter@80
   213
    B b = functorToMap(F())[A()];
alpar@1083
   214
    ::lemon::ignore_unused_variable_warning(b);
kpeter@80
   215
kpeter@80
   216
    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
alpar@997
   217
    MapToFunctor<ReadMap<A,B> > map =
alpar@997
   218
      MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
alpar@1083
   219
    ::lemon::ignore_unused_variable_warning(map);
kpeter@80
   220
alpar@210
   221
    check(functorToMap(&func)[A()] == 3,
alpar@210
   222
          "Something is wrong with FunctorToMap");
alpar@210
   223
    check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
alpar@210
   224
          "Something is wrong with MapToFunctor");
alpar@210
   225
    check(mapToFunctor(functorToMap(&func))(A()) == 3 &&
alpar@210
   226
          mapToFunctor(functorToMap(&func))[A()] == 3,
kpeter@80
   227
          "Something is wrong with FunctorToMap or MapToFunctor");
kpeter@80
   228
    check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2,
kpeter@80
   229
          "Something is wrong with FunctorToMap or MapToFunctor");
kpeter@80
   230
  }
kpeter@80
   231
kpeter@80
   232
  // ConvertMap
kpeter@80
   233
  {
alpar@210
   234
    checkConcept<ReadMap<double,double>,
alpar@210
   235
      ConvertMap<ReadMap<double, int>, double> >();
kpeter@80
   236
    ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true));
alpar@1083
   237
    ::lemon::ignore_unused_variable_warning(map1);
kpeter@80
   238
    ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false));
alpar@1083
   239
    ::lemon::ignore_unused_variable_warning(map2);
alpar@997
   240
kpeter@80
   241
  }
kpeter@80
   242
kpeter@80
   243
  // ForkMap
kpeter@80
   244
  {
kpeter@80
   245
    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
kpeter@82
   246
kpeter@80
   247
    typedef RangeMap<double> RM;
kpeter@80
   248
    typedef SparseMap<int, double> SM;
kpeter@80
   249
    RM m1(10, -1);
kpeter@80
   250
    SM m2(-1);
kpeter@80
   251
    checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >();
kpeter@80
   252
    checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >();
kpeter@80
   253
    ForkMap<RM, SM> map1(m1,m2);
kpeter@80
   254
    ForkMap<SM, RM> map2 = forkMap(m2,m1);
kpeter@80
   255
    map2.set(5, 10);
alpar@210
   256
    check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 &&
alpar@210
   257
          m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
kpeter@80
   258
          "Something is wrong with ForkMap");
kpeter@80
   259
  }
kpeter@82
   260
kpeter@80
   261
  // Arithmetic maps:
kpeter@80
   262
  // - AddMap, SubMap, MulMap, DivMap
kpeter@80
   263
  // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
kpeter@80
   264
  // - NegMap, NegWriteMap, AbsMap
kpeter@80
   265
  {
kpeter@80
   266
    checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >();
kpeter@80
   267
    checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
kpeter@80
   268
    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
kpeter@80
   269
    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
kpeter@82
   270
kpeter@80
   271
    ConstMap<int, double> c1(1.0), c2(3.14);
kpeter@80
   272
    IdentityMap<int> im;
kpeter@80
   273
    ConvertMap<IdentityMap<int>, double> id(im);
alpar@210
   274
    check(addMap(c1,id)[0] == 1.0  && addMap(c1,id)[10] == 11.0,
alpar@210
   275
          "Something is wrong with AddMap");
alpar@210
   276
    check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,
alpar@210
   277
          "Something is wrong with SubMap");
alpar@210
   278
    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28,
alpar@210
   279
          "Something is wrong with MulMap");
alpar@210
   280
    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57,
alpar@210
   281
          "Something is wrong with DivMap");
kpeter@82
   282
kpeter@80
   283
    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
kpeter@80
   284
    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
kpeter@80
   285
    checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
kpeter@80
   286
    checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >();
kpeter@80
   287
    checkConcept<DoubleMap, NegMap<DoubleMap> >();
kpeter@80
   288
    checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >();
kpeter@80
   289
    checkConcept<DoubleMap, AbsMap<DoubleMap> >();
alpar@25
   290
kpeter@80
   291
    check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0,
kpeter@80
   292
          "Something is wrong with ShiftMap");
alpar@210
   293
    check(shiftWriteMap(id, 2.0)[1] == 3.0 &&
alpar@210
   294
          shiftWriteMap(id, 2.0)[10] == 12.0,
kpeter@80
   295
          "Something is wrong with ShiftWriteMap");
kpeter@80
   296
    check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0,
kpeter@80
   297
          "Something is wrong with ScaleMap");
alpar@210
   298
    check(scaleWriteMap(id, 2.0)[1] == 2.0 &&
alpar@210
   299
          scaleWriteMap(id, 2.0)[10] == 20.0,
kpeter@80
   300
          "Something is wrong with ScaleWriteMap");
kpeter@80
   301
    check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0,
kpeter@80
   302
          "Something is wrong with NegMap");
kpeter@80
   303
    check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0,
kpeter@80
   304
          "Something is wrong with NegWriteMap");
kpeter@80
   305
    check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
kpeter@80
   306
          "Something is wrong with AbsMap");
kpeter@80
   307
  }
kpeter@82
   308
kpeter@82
   309
  // Logical maps:
kpeter@82
   310
  // - TrueMap, FalseMap
kpeter@82
   311
  // - AndMap, OrMap
kpeter@82
   312
  // - NotMap, NotWriteMap
kpeter@82
   313
  // - EqualMap, LessMap
kpeter@80
   314
  {
kpeter@82
   315
    checkConcept<BoolMap, TrueMap<A> >();
kpeter@82
   316
    checkConcept<BoolMap, FalseMap<A> >();
kpeter@82
   317
    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
kpeter@82
   318
    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
kpeter@80
   319
    checkConcept<BoolMap, NotMap<BoolMap> >();
kpeter@80
   320
    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
kpeter@82
   321
    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
kpeter@82
   322
    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
kpeter@82
   323
kpeter@82
   324
    TrueMap<int> tm;
kpeter@82
   325
    FalseMap<int> fm;
kpeter@80
   326
    RangeMap<bool> rm(2);
kpeter@80
   327
    rm[0] = true; rm[1] = false;
alpar@210
   328
    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] &&
alpar@210
   329
          !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
kpeter@82
   330
          "Something is wrong with AndMap");
alpar@210
   331
    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] &&
alpar@210
   332
          orMap(fm,rm)[0] && !orMap(fm,rm)[1],
kpeter@82
   333
          "Something is wrong with OrMap");
alpar@210
   334
    check(!notMap(rm)[0] && notMap(rm)[1],
alpar@210
   335
          "Something is wrong with NotMap");
alpar@210
   336
    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1],
alpar@210
   337
          "Something is wrong with NotWriteMap");
kpeter@82
   338
kpeter@82
   339
    ConstMap<int, double> cm(2.0);
kpeter@82
   340
    IdentityMap<int> im;
kpeter@82
   341
    ConvertMap<IdentityMap<int>, double> id(im);
kpeter@82
   342
    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
kpeter@82
   343
          "Something is wrong with LessMap");
kpeter@82
   344
    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
kpeter@82
   345
          "Something is wrong with EqualMap");
kpeter@80
   346
  }
alpar@209
   347
kpeter@167
   348
  // LoggerBoolMap
kpeter@159
   349
  {
kpeter@159
   350
    typedef std::vector<int> vec;
kpeter@159
   351
    vec v1;
kpeter@159
   352
    vec v2(10);
alpar@210
   353
    LoggerBoolMap<std::back_insert_iterator<vec> >
alpar@210
   354
      map1(std::back_inserter(v1));
kpeter@167
   355
    LoggerBoolMap<vec::iterator> map2(v2.begin());
kpeter@159
   356
    map1.set(10, false);
kpeter@159
   357
    map1.set(20, true);   map2.set(20, true);
kpeter@159
   358
    map1.set(30, false);  map2.set(40, false);
kpeter@159
   359
    map1.set(50, true);   map2.set(50, true);
kpeter@159
   360
    map1.set(60, true);   map2.set(60, true);
kpeter@159
   361
    check(v1.size() == 3 && v2.size() == 10 &&
alpar@210
   362
          v1[0]==20 && v1[1]==50 && v1[2]==60 &&
alpar@210
   363
          v2[0]==20 && v2[1]==50 && v2[2]==60,
kpeter@167
   364
          "Something is wrong with LoggerBoolMap");
alpar@209
   365
kpeter@159
   366
    int i = 0;
kpeter@167
   367
    for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
kpeter@159
   368
          it != map2.end(); ++it )
kpeter@167
   369
      check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
kpeter@159
   370
  }
kpeter@684
   371
  
kpeter@684
   372
  // CrossRefMap
kpeter@684
   373
  {
kpeter@684
   374
    typedef ListDigraph Graph;
kpeter@684
   375
    DIGRAPH_TYPEDEFS(Graph);
kpeter@684
   376
kpeter@684
   377
    checkConcept<ReadWriteMap<Node, int>,
kpeter@684
   378
                 CrossRefMap<Graph, Node, int> >();
kpeter@684
   379
    
kpeter@684
   380
    Graph gr;
kpeter@684
   381
    typedef CrossRefMap<Graph, Node, char> CRMap;
kpeter@684
   382
    typedef CRMap::ValueIterator ValueIt;
kpeter@684
   383
    CRMap map(gr);
kpeter@684
   384
    
kpeter@684
   385
    Node n0 = gr.addNode();
kpeter@684
   386
    Node n1 = gr.addNode();
kpeter@684
   387
    Node n2 = gr.addNode();
kpeter@684
   388
    
kpeter@684
   389
    map.set(n0, 'A');
kpeter@684
   390
    map.set(n1, 'B');
kpeter@684
   391
    map.set(n2, 'C');
kpeter@684
   392
    map.set(n2, 'A');
kpeter@684
   393
    map.set(n0, 'C');
kpeter@684
   394
kpeter@684
   395
    check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
kpeter@684
   396
          "Wrong CrossRefMap");
kpeter@684
   397
    check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
kpeter@684
   398
    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
kpeter@684
   399
    check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
kpeter@684
   400
kpeter@684
   401
    ValueIt it = map.beginValue();
kpeter@684
   402
    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
kpeter@684
   403
          it == map.endValue(), "Wrong value iterator");
kpeter@684
   404
  }
alpar@25
   405
alpar@25
   406
  return 0;
alpar@25
   407
}