Fix compilation error when NDEBUG is defined.
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_TEST_MAP_TEST_H
20 #define LEMON_TEST_MAP_TEST_H
23 #include <lemon/maps.h>
25 #include "test_tools.h"
29 template <typename Graph>
30 void checkGraphNodeMap() {
34 typedef typename Graph::Node Node;
36 std::vector<Node> nodes;
37 for (int i = 0; i < num; ++i) {
38 nodes.push_back(graph.addNode());
40 typedef typename Graph::template NodeMap<int> IntNodeMap;
41 IntNodeMap map(graph, 42);
42 for (int i = 0; i < int(nodes.size()); ++i) {
43 check(map[nodes[i]] == 42, "Wrong map constructor.");
45 for (int i = 0; i < num; ++i) {
46 nodes.push_back(graph.addNode());
47 map[nodes.back()] = 23;
48 check(map[nodes.back()] == 23, "Wrong operator[].");
50 map = constMap<Node>(12);
51 for (int i = 0; i < int(nodes.size()); ++i) {
52 check(map[nodes[i]] == 12, "Wrong map constructor.");
58 template <typename Graph>
59 void checkGraphArcMap() {
63 typedef typename Graph::Node Node;
64 typedef typename Graph::Arc Arc;
66 std::vector<Node> nodes;
67 for (int i = 0; i < num; ++i) {
68 nodes.push_back(graph.addNode());
71 std::vector<Arc> arcs;
72 for (int i = 0; i < num; ++i) {
73 for (int j = 0; j < i; ++j) {
74 arcs.push_back(graph.addArc(nodes[i], nodes[j]));
78 typedef typename Graph::template ArcMap<int> IntArcMap;
79 IntArcMap map(graph, 42);
81 for (int i = 0; i < int(arcs.size()); ++i) {
82 check(map[arcs[i]] == 42, "Wrong map constructor.");
85 for (int i = 0; i < num; ++i) {
86 for (int j = i + 1; j < num; ++j) {
87 arcs.push_back(graph.addArc(nodes[i], nodes[j]));
88 map[arcs.back()] = 23;
89 check(map[arcs.back()] == 23, "Wrong operator[].");
92 map = constMap<Arc>(12);
93 for (int i = 0; i < int(arcs.size()); ++i) {
94 check(map[arcs[i]] == 12, "Wrong map constructor.");
100 template <typename Graph>
101 void checkGraphEdgeMap() {
105 typedef typename Graph::Node Node;
106 typedef typename Graph::Edge Edge;
108 std::vector<Node> nodes;
109 for (int i = 0; i < num; ++i) {
110 nodes.push_back(graph.addNode());
113 std::vector<Edge> edges;
114 for (int i = 0; i < num; ++i) {
115 for (int j = 0; j < i; ++j) {
116 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
120 typedef typename Graph::template EdgeMap<int> IntEdgeMap;
121 IntEdgeMap map(graph, 42);
123 for (int i = 0; i < int(edges.size()); ++i) {
124 check(map[edges[i]] == 42, "Wrong map constructor.");
127 for (int i = 0; i < num; ++i) {
128 for (int j = i + 1; j < num; ++j) {
129 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
130 map[edges.back()] = 23;
131 check(map[edges.back()] == 23, "Wrong operator[].");
134 map = constMap<Edge>(12);
135 for (int i = 0; i < int(edges.size()); ++i) {
136 check(map[edges[i]] == 12, "Wrong map constructor.");