Coding of Algorithms has begun, but code is really-really ugly yet.
2 * test/map_test.h - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
16 #ifndef LEMON_TEST_MAP_TEST_H
17 #define LEMON_TEST_MAP_TEST_H
22 #include "test_tools.h"
27 //! \brief Some utilities to test map classes.
32 template <typename Graph>
33 void checkGraphNodeMap() {
37 typedef typename Graph::Node Node;
39 std::vector<Node> nodes;
40 for (int i = 0; i < num; ++i) {
41 nodes.push_back(graph.addNode());
43 typedef typename Graph::template NodeMap<int> IntNodeMap;
44 IntNodeMap map(graph, 42);
45 for (int i = 0; i < (int)nodes.size(); ++i) {
46 check(map[nodes[i]] == 42, "Wrong map constructor.");
48 for (int i = 0; i < num; ++i) {
49 nodes.push_back(graph.addNode());
50 map[nodes.back()] = 23;
52 map = constMap<Node>(12);
53 for (int i = 0; i < (int)nodes.size(); ++i) {
54 check(map[nodes[i]] == 12, "Wrong map constructor.");
60 template <typename Graph>
61 void checkGraphEdgeMap() {
65 typedef typename Graph::Node Node;
66 typedef typename Graph::Edge Edge;
68 std::vector<Node> nodes;
69 for (int i = 0; i < num; ++i) {
70 nodes.push_back(graph.addNode());
73 std::vector<Edge> edges;
74 for (int i = 0; i < num; ++i) {
75 for (int j = 0; j < i; ++j) {
76 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
80 typedef typename Graph::template EdgeMap<int> IntEdgeMap;
81 IntEdgeMap map(graph, 42);
83 for (int i = 0; i < (int)edges.size(); ++i) {
84 check(map[edges[i]] == 42, "Wrong map constructor.");
87 for (int i = 0; i < num; ++i) {
88 for (int j = i + 1; j < num; ++j) {
89 edges.push_back(graph.addEdge(nodes[i], nodes[j]));
90 map[edges.back()] = 23;
93 map = constMap<Edge>(12);
94 for (int i = 0; i < (int)edges.size(); ++i) {
95 check(map[edges[i]] == 12, "Wrong map constructor.");