1.1 --- a/test/maps_test.cc Mon Jan 12 23:11:39 2009 +0100
1.2 +++ b/test/maps_test.cc Thu Nov 05 15:48:01 2009 +0100
1.3 @@ -22,6 +22,10 @@
1.4 #include <lemon/concept_check.h>
1.5 #include <lemon/concepts/maps.h>
1.6 #include <lemon/maps.h>
1.7 +#include <lemon/list_graph.h>
1.8 +#include <lemon/smart_graph.h>
1.9 +#include <lemon/adaptors.h>
1.10 +#include <lemon/dfs.h>
1.11
1.12 #include "test_tools.h"
1.13
1.14 @@ -60,6 +64,12 @@
1.15 typedef ReadWriteMap<A, bool> BoolWriteMap;
1.16 typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
1.17
1.18 +template<typename Map1, typename Map2, typename ItemIt>
1.19 +void compareMap(const Map1& map1, const Map2& map2, ItemIt it) {
1.20 + for (; it != INVALID; ++it)
1.21 + check(map1[it] == map2[it], "The maps are not equal");
1.22 +}
1.23 +
1.24 int main()
1.25 {
1.26 // Map concepts
1.27 @@ -170,7 +180,7 @@
1.28 {
1.29 typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
1.30 checkConcept<ReadMap<B,double>, CompMap>();
1.31 - CompMap map1(DoubleMap(),ReadMap<B,A>());
1.32 + CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>());
1.33 CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
1.34
1.35 SparseMap<double, bool> m1(false); m1[3.14] = true;
1.36 @@ -183,7 +193,7 @@
1.37 {
1.38 typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
1.39 checkConcept<ReadMap<A,double>, CombMap>();
1.40 - CombMap map1(DoubleMap(), DoubleMap());
1.41 + CombMap map1 = CombMap(DoubleMap(), DoubleMap());
1.42 CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
1.43
1.44 check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
1.45 @@ -195,11 +205,11 @@
1.46 checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
1.47 checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
1.48 FunctorToMap<F> map1;
1.49 - FunctorToMap<F> map2(F());
1.50 + FunctorToMap<F> map2 = FunctorToMap<F>(F());
1.51 B b = functorToMap(F())[A()];
1.52
1.53 checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
1.54 - MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>());
1.55 + MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
1.56
1.57 check(functorToMap(&func)[A()] == 3,
1.58 "Something is wrong with FunctorToMap");
1.59 @@ -328,6 +338,10 @@
1.60 // LoggerBoolMap
1.61 {
1.62 typedef std::vector<int> vec;
1.63 + checkConcept<WriteMap<int, bool>, LoggerBoolMap<vec::iterator> >();
1.64 + checkConcept<WriteMap<int, bool>,
1.65 + LoggerBoolMap<std::back_insert_iterator<vec> > >();
1.66 +
1.67 vec v1;
1.68 vec v2(10);
1.69 LoggerBoolMap<std::back_insert_iterator<vec> >
1.70 @@ -347,7 +361,444 @@
1.71 for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
1.72 it != map2.end(); ++it )
1.73 check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
1.74 +
1.75 + typedef ListDigraph Graph;
1.76 + DIGRAPH_TYPEDEFS(Graph);
1.77 + Graph gr;
1.78 +
1.79 + Node n0 = gr.addNode();
1.80 + Node n1 = gr.addNode();
1.81 + Node n2 = gr.addNode();
1.82 + Node n3 = gr.addNode();
1.83 +
1.84 + gr.addArc(n3, n0);
1.85 + gr.addArc(n3, n2);
1.86 + gr.addArc(n0, n2);
1.87 + gr.addArc(n2, n1);
1.88 + gr.addArc(n0, n1);
1.89 +
1.90 + {
1.91 + std::vector<Node> v;
1.92 + dfs(gr).processedMap(loggerBoolMap(std::back_inserter(v))).run();
1.93 +
1.94 + check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3,
1.95 + "Something is wrong with LoggerBoolMap");
1.96 + }
1.97 + {
1.98 + std::vector<Node> v(countNodes(gr));
1.99 + dfs(gr).processedMap(loggerBoolMap(v.begin())).run();
1.100 +
1.101 + check(v.size()==4 && v[0]==n1 && v[1]==n2 && v[2]==n0 && v[3]==n3,
1.102 + "Something is wrong with LoggerBoolMap");
1.103 + }
1.104 + }
1.105 +
1.106 + // IdMap, RangeIdMap
1.107 + {
1.108 + typedef ListDigraph Graph;
1.109 + DIGRAPH_TYPEDEFS(Graph);
1.110 +
1.111 + checkConcept<ReadMap<Node, int>, IdMap<Graph, Node> >();
1.112 + checkConcept<ReadMap<Arc, int>, IdMap<Graph, Arc> >();
1.113 + checkConcept<ReadMap<Node, int>, RangeIdMap<Graph, Node> >();
1.114 + checkConcept<ReadMap<Arc, int>, RangeIdMap<Graph, Arc> >();
1.115 +
1.116 + Graph gr;
1.117 + IdMap<Graph, Node> nmap(gr);
1.118 + IdMap<Graph, Arc> amap(gr);
1.119 + RangeIdMap<Graph, Node> nrmap(gr);
1.120 + RangeIdMap<Graph, Arc> armap(gr);
1.121 +
1.122 + Node n0 = gr.addNode();
1.123 + Node n1 = gr.addNode();
1.124 + Node n2 = gr.addNode();
1.125 +
1.126 + Arc a0 = gr.addArc(n0, n1);
1.127 + Arc a1 = gr.addArc(n0, n2);
1.128 + Arc a2 = gr.addArc(n2, n1);
1.129 + Arc a3 = gr.addArc(n2, n0);
1.130 +
1.131 + check(nmap[n0] == gr.id(n0) && nmap(gr.id(n0)) == n0, "Wrong IdMap");
1.132 + check(nmap[n1] == gr.id(n1) && nmap(gr.id(n1)) == n1, "Wrong IdMap");
1.133 + check(nmap[n2] == gr.id(n2) && nmap(gr.id(n2)) == n2, "Wrong IdMap");
1.134 +
1.135 + check(amap[a0] == gr.id(a0) && amap(gr.id(a0)) == a0, "Wrong IdMap");
1.136 + check(amap[a1] == gr.id(a1) && amap(gr.id(a1)) == a1, "Wrong IdMap");
1.137 + check(amap[a2] == gr.id(a2) && amap(gr.id(a2)) == a2, "Wrong IdMap");
1.138 + check(amap[a3] == gr.id(a3) && amap(gr.id(a3)) == a3, "Wrong IdMap");
1.139 +
1.140 + check(nmap.inverse()[gr.id(n0)] == n0, "Wrong IdMap::InverseMap");
1.141 + check(amap.inverse()[gr.id(a0)] == a0, "Wrong IdMap::InverseMap");
1.142 +
1.143 + check(nrmap.size() == 3 && armap.size() == 4,
1.144 + "Wrong RangeIdMap::size()");
1.145 +
1.146 + check(nrmap[n0] == 0 && nrmap(0) == n0, "Wrong RangeIdMap");
1.147 + check(nrmap[n1] == 1 && nrmap(1) == n1, "Wrong RangeIdMap");
1.148 + check(nrmap[n2] == 2 && nrmap(2) == n2, "Wrong RangeIdMap");
1.149 +
1.150 + check(armap[a0] == 0 && armap(0) == a0, "Wrong RangeIdMap");
1.151 + check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
1.152 + check(armap[a2] == 2 && armap(2) == a2, "Wrong RangeIdMap");
1.153 + check(armap[a3] == 3 && armap(3) == a3, "Wrong RangeIdMap");
1.154 +
1.155 + check(nrmap.inverse()[0] == n0, "Wrong RangeIdMap::InverseMap");
1.156 + check(armap.inverse()[0] == a0, "Wrong RangeIdMap::InverseMap");
1.157 +
1.158 + gr.erase(n1);
1.159 +
1.160 + if (nrmap[n0] == 1) nrmap.swap(n0, n2);
1.161 + nrmap.swap(n2, n0);
1.162 + if (armap[a1] == 1) armap.swap(a1, a3);
1.163 + armap.swap(a3, a1);
1.164 +
1.165 + check(nrmap.size() == 2 && armap.size() == 2,
1.166 + "Wrong RangeIdMap::size()");
1.167 +
1.168 + check(nrmap[n0] == 1 && nrmap(1) == n0, "Wrong RangeIdMap");
1.169 + check(nrmap[n2] == 0 && nrmap(0) == n2, "Wrong RangeIdMap");
1.170 +
1.171 + check(armap[a1] == 1 && armap(1) == a1, "Wrong RangeIdMap");
1.172 + check(armap[a3] == 0 && armap(0) == a3, "Wrong RangeIdMap");
1.173 +
1.174 + check(nrmap.inverse()[0] == n2, "Wrong RangeIdMap::InverseMap");
1.175 + check(armap.inverse()[0] == a3, "Wrong RangeIdMap::InverseMap");
1.176 + }
1.177 +
1.178 + // SourceMap, TargetMap, ForwardMap, BackwardMap, InDegMap, OutDegMap
1.179 + {
1.180 + typedef ListGraph Graph;
1.181 + GRAPH_TYPEDEFS(Graph);
1.182 +
1.183 + checkConcept<ReadMap<Arc, Node>, SourceMap<Graph> >();
1.184 + checkConcept<ReadMap<Arc, Node>, TargetMap<Graph> >();
1.185 + checkConcept<ReadMap<Edge, Arc>, ForwardMap<Graph> >();
1.186 + checkConcept<ReadMap<Edge, Arc>, BackwardMap<Graph> >();
1.187 + checkConcept<ReadMap<Node, int>, InDegMap<Graph> >();
1.188 + checkConcept<ReadMap<Node, int>, OutDegMap<Graph> >();
1.189 +
1.190 + Graph gr;
1.191 + Node n0 = gr.addNode();
1.192 + Node n1 = gr.addNode();
1.193 + Node n2 = gr.addNode();
1.194 +
1.195 + gr.addEdge(n0,n1);
1.196 + gr.addEdge(n1,n2);
1.197 + gr.addEdge(n0,n2);
1.198 + gr.addEdge(n2,n1);
1.199 + gr.addEdge(n1,n2);
1.200 + gr.addEdge(n0,n1);
1.201 +
1.202 + for (EdgeIt e(gr); e != INVALID; ++e) {
1.203 + check(forwardMap(gr)[e] == gr.direct(e, true), "Wrong ForwardMap");
1.204 + check(backwardMap(gr)[e] == gr.direct(e, false), "Wrong BackwardMap");
1.205 + }
1.206 +
1.207 + compareMap(sourceMap(orienter(gr, constMap<Edge, bool>(true))),
1.208 + targetMap(orienter(gr, constMap<Edge, bool>(false))),
1.209 + EdgeIt(gr));
1.210 +
1.211 + typedef Orienter<Graph, const ConstMap<Edge, bool> > Digraph;
1.212 + Digraph dgr(gr, constMap<Edge, bool>(true));
1.213 + OutDegMap<Digraph> odm(dgr);
1.214 + InDegMap<Digraph> idm(dgr);
1.215 +
1.216 + check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 1, "Wrong OutDegMap");
1.217 + check(idm[n0] == 0 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
1.218 +
1.219 + gr.addEdge(n2, n0);
1.220 +
1.221 + check(odm[n0] == 3 && odm[n1] == 2 && odm[n2] == 2, "Wrong OutDegMap");
1.222 + check(idm[n0] == 1 && idm[n1] == 3 && idm[n2] == 3, "Wrong InDegMap");
1.223 + }
1.224 +
1.225 + // CrossRefMap
1.226 + {
1.227 + typedef ListDigraph Graph;
1.228 + DIGRAPH_TYPEDEFS(Graph);
1.229 +
1.230 + checkConcept<ReadWriteMap<Node, int>,
1.231 + CrossRefMap<Graph, Node, int> >();
1.232 + checkConcept<ReadWriteMap<Node, bool>,
1.233 + CrossRefMap<Graph, Node, bool> >();
1.234 + checkConcept<ReadWriteMap<Node, double>,
1.235 + CrossRefMap<Graph, Node, double> >();
1.236 +
1.237 + Graph gr;
1.238 + typedef CrossRefMap<Graph, Node, char> CRMap;
1.239 + CRMap map(gr);
1.240 +
1.241 + Node n0 = gr.addNode();
1.242 + Node n1 = gr.addNode();
1.243 + Node n2 = gr.addNode();
1.244 +
1.245 + map.set(n0, 'A');
1.246 + map.set(n1, 'B');
1.247 + map.set(n2, 'C');
1.248 +
1.249 + check(map[n0] == 'A' && map('A') == n0 && map.inverse()['A'] == n0,
1.250 + "Wrong CrossRefMap");
1.251 + check(map[n1] == 'B' && map('B') == n1 && map.inverse()['B'] == n1,
1.252 + "Wrong CrossRefMap");
1.253 + check(map[n2] == 'C' && map('C') == n2 && map.inverse()['C'] == n2,
1.254 + "Wrong CrossRefMap");
1.255 + check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
1.256 + "Wrong CrossRefMap::count()");
1.257 +
1.258 + CRMap::ValueIt it = map.beginValue();
1.259 + check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
1.260 + it == map.endValue(), "Wrong value iterator");
1.261 +
1.262 + map.set(n2, 'A');
1.263 +
1.264 + check(map[n0] == 'A' && map[n1] == 'B' && map[n2] == 'A',
1.265 + "Wrong CrossRefMap");
1.266 + check(map('A') == n0 && map.inverse()['A'] == n0, "Wrong CrossRefMap");
1.267 + check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
1.268 + check(map('C') == INVALID && map.inverse()['C'] == INVALID,
1.269 + "Wrong CrossRefMap");
1.270 + check(map.count('A') == 2 && map.count('B') == 1 && map.count('C') == 0,
1.271 + "Wrong CrossRefMap::count()");
1.272 +
1.273 + it = map.beginValue();
1.274 + check(*it++ == 'A' && *it++ == 'A' && *it++ == 'B' &&
1.275 + it == map.endValue(), "Wrong value iterator");
1.276 +
1.277 + map.set(n0, 'C');
1.278 +
1.279 + check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
1.280 + "Wrong CrossRefMap");
1.281 + check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
1.282 + check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
1.283 + check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
1.284 + check(map.count('A') == 1 && map.count('B') == 1 && map.count('C') == 1,
1.285 + "Wrong CrossRefMap::count()");
1.286 +
1.287 + it = map.beginValue();
1.288 + check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
1.289 + it == map.endValue(), "Wrong value iterator");
1.290 }
1.291
1.292 + // CrossRefMap
1.293 + {
1.294 + typedef SmartDigraph Graph;
1.295 + DIGRAPH_TYPEDEFS(Graph);
1.296 +
1.297 + checkConcept<ReadWriteMap<Node, int>,
1.298 + CrossRefMap<Graph, Node, int> >();
1.299 +
1.300 + Graph gr;
1.301 + typedef CrossRefMap<Graph, Node, char> CRMap;
1.302 + typedef CRMap::ValueIterator ValueIt;
1.303 + CRMap map(gr);
1.304 +
1.305 + Node n0 = gr.addNode();
1.306 + Node n1 = gr.addNode();
1.307 + Node n2 = gr.addNode();
1.308 +
1.309 + map.set(n0, 'A');
1.310 + map.set(n1, 'B');
1.311 + map.set(n2, 'C');
1.312 + map.set(n2, 'A');
1.313 + map.set(n0, 'C');
1.314 +
1.315 + check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
1.316 + "Wrong CrossRefMap");
1.317 + check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
1.318 + check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
1.319 + check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
1.320 +
1.321 + ValueIt it = map.beginValue();
1.322 + check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
1.323 + it == map.endValue(), "Wrong value iterator");
1.324 + }
1.325 +
1.326 + // Iterable bool map
1.327 + {
1.328 + typedef SmartGraph Graph;
1.329 + typedef SmartGraph::Node Item;
1.330 +
1.331 + typedef IterableBoolMap<SmartGraph, SmartGraph::Node> Ibm;
1.332 + checkConcept<ReferenceMap<Item, bool, bool&, const bool&>, Ibm>();
1.333 +
1.334 + const int num = 10;
1.335 + Graph g;
1.336 + std::vector<Item> items;
1.337 + for (int i = 0; i < num; ++i) {
1.338 + items.push_back(g.addNode());
1.339 + }
1.340 +
1.341 + Ibm map1(g, true);
1.342 + int n = 0;
1.343 + for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
1.344 + check(map1[static_cast<Item>(it)], "Wrong TrueIt");
1.345 + ++n;
1.346 + }
1.347 + check(n == num, "Wrong number");
1.348 +
1.349 + n = 0;
1.350 + for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) {
1.351 + check(map1[static_cast<Item>(it)], "Wrong ItemIt for true");
1.352 + ++n;
1.353 + }
1.354 + check(n == num, "Wrong number");
1.355 + check(Ibm::FalseIt(map1) == INVALID, "Wrong FalseIt");
1.356 + check(Ibm::ItemIt(map1, false) == INVALID, "Wrong ItemIt for false");
1.357 +
1.358 + map1[items[5]] = true;
1.359 +
1.360 + n = 0;
1.361 + for (Ibm::ItemIt it(map1, true); it != INVALID; ++it) {
1.362 + check(map1[static_cast<Item>(it)], "Wrong ItemIt for true");
1.363 + ++n;
1.364 + }
1.365 + check(n == num, "Wrong number");
1.366 +
1.367 + map1[items[num / 2]] = false;
1.368 + check(map1[items[num / 2]] == false, "Wrong map value");
1.369 +
1.370 + n = 0;
1.371 + for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
1.372 + check(map1[static_cast<Item>(it)], "Wrong TrueIt for true");
1.373 + ++n;
1.374 + }
1.375 + check(n == num - 1, "Wrong number");
1.376 +
1.377 + n = 0;
1.378 + for (Ibm::FalseIt it(map1); it != INVALID; ++it) {
1.379 + check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
1.380 + ++n;
1.381 + }
1.382 + check(n == 1, "Wrong number");
1.383 +
1.384 + map1[items[0]] = false;
1.385 + check(map1[items[0]] == false, "Wrong map value");
1.386 +
1.387 + map1[items[num - 1]] = false;
1.388 + check(map1[items[num - 1]] == false, "Wrong map value");
1.389 +
1.390 + n = 0;
1.391 + for (Ibm::TrueIt it(map1); it != INVALID; ++it) {
1.392 + check(map1[static_cast<Item>(it)], "Wrong TrueIt for true");
1.393 + ++n;
1.394 + }
1.395 + check(n == num - 3, "Wrong number");
1.396 + check(map1.trueNum() == num - 3, "Wrong number");
1.397 +
1.398 + n = 0;
1.399 + for (Ibm::FalseIt it(map1); it != INVALID; ++it) {
1.400 + check(!map1[static_cast<Item>(it)], "Wrong FalseIt for true");
1.401 + ++n;
1.402 + }
1.403 + check(n == 3, "Wrong number");
1.404 + check(map1.falseNum() == 3, "Wrong number");
1.405 + }
1.406 +
1.407 + // Iterable int map
1.408 + {
1.409 + typedef SmartGraph Graph;
1.410 + typedef SmartGraph::Node Item;
1.411 + typedef IterableIntMap<SmartGraph, SmartGraph::Node> Iim;
1.412 +
1.413 + checkConcept<ReferenceMap<Item, int, int&, const int&>, Iim>();
1.414 +
1.415 + const int num = 10;
1.416 + Graph g;
1.417 + std::vector<Item> items;
1.418 + for (int i = 0; i < num; ++i) {
1.419 + items.push_back(g.addNode());
1.420 + }
1.421 +
1.422 + Iim map1(g);
1.423 + check(map1.size() == 0, "Wrong size");
1.424 +
1.425 + for (int i = 0; i < num; ++i) {
1.426 + map1[items[i]] = i;
1.427 + }
1.428 + check(map1.size() == num, "Wrong size");
1.429 +
1.430 + for (int i = 0; i < num; ++i) {
1.431 + Iim::ItemIt it(map1, i);
1.432 + check(static_cast<Item>(it) == items[i], "Wrong value");
1.433 + ++it;
1.434 + check(static_cast<Item>(it) == INVALID, "Wrong value");
1.435 + }
1.436 +
1.437 + for (int i = 0; i < num; ++i) {
1.438 + map1[items[i]] = i % 2;
1.439 + }
1.440 + check(map1.size() == 2, "Wrong size");
1.441 +
1.442 + int n = 0;
1.443 + for (Iim::ItemIt it(map1, 0); it != INVALID; ++it) {
1.444 + check(map1[static_cast<Item>(it)] == 0, "Wrong value");
1.445 + ++n;
1.446 + }
1.447 + check(n == (num + 1) / 2, "Wrong number");
1.448 +
1.449 + for (Iim::ItemIt it(map1, 1); it != INVALID; ++it) {
1.450 + check(map1[static_cast<Item>(it)] == 1, "Wrong value");
1.451 + ++n;
1.452 + }
1.453 + check(n == num, "Wrong number");
1.454 +
1.455 + }
1.456 +
1.457 + // Iterable value map
1.458 + {
1.459 + typedef SmartGraph Graph;
1.460 + typedef SmartGraph::Node Item;
1.461 + typedef IterableValueMap<SmartGraph, SmartGraph::Node, double> Ivm;
1.462 +
1.463 + checkConcept<ReadWriteMap<Item, double>, Ivm>();
1.464 +
1.465 + const int num = 10;
1.466 + Graph g;
1.467 + std::vector<Item> items;
1.468 + for (int i = 0; i < num; ++i) {
1.469 + items.push_back(g.addNode());
1.470 + }
1.471 +
1.472 + Ivm map1(g, 0.0);
1.473 + check(distance(map1.beginValue(), map1.endValue()) == 1, "Wrong size");
1.474 + check(*map1.beginValue() == 0.0, "Wrong value");
1.475 +
1.476 + for (int i = 0; i < num; ++i) {
1.477 + map1.set(items[i], static_cast<double>(i));
1.478 + }
1.479 + check(distance(map1.beginValue(), map1.endValue()) == num, "Wrong size");
1.480 +
1.481 + for (int i = 0; i < num; ++i) {
1.482 + Ivm::ItemIt it(map1, static_cast<double>(i));
1.483 + check(static_cast<Item>(it) == items[i], "Wrong value");
1.484 + ++it;
1.485 + check(static_cast<Item>(it) == INVALID, "Wrong value");
1.486 + }
1.487 +
1.488 + for (Ivm::ValueIt vit = map1.beginValue();
1.489 + vit != map1.endValue(); ++vit) {
1.490 + check(map1[static_cast<Item>(Ivm::ItemIt(map1, *vit))] == *vit,
1.491 + "Wrong ValueIt");
1.492 + }
1.493 +
1.494 + for (int i = 0; i < num; ++i) {
1.495 + map1.set(items[i], static_cast<double>(i % 2));
1.496 + }
1.497 + check(distance(map1.beginValue(), map1.endValue()) == 2, "Wrong size");
1.498 +
1.499 + int n = 0;
1.500 + for (Ivm::ItemIt it(map1, 0.0); it != INVALID; ++it) {
1.501 + check(map1[static_cast<Item>(it)] == 0.0, "Wrong value");
1.502 + ++n;
1.503 + }
1.504 + check(n == (num + 1) / 2, "Wrong number");
1.505 +
1.506 + for (Ivm::ItemIt it(map1, 1.0); it != INVALID; ++it) {
1.507 + check(map1[static_cast<Item>(it)] == 1.0, "Wrong value");
1.508 + ++n;
1.509 + }
1.510 + check(n == num, "Wrong number");
1.511 +
1.512 + }
1.513 return 0;
1.514 }