COIN-OR::LEMON - Graph Library

Changeset 684:7b1a6e963018 in lemon-main for test


Ignore:
Timestamp:
07/23/09 18:09:41 (15 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Children:
685:a27356ceb5bd, 720:6e8c27ee9079
Phase:
public
Message:

Fix the implementation and doc of CrossRefMap? (#302)

  • Handle multiple values correctly with std::multimap.
  • Clarify the problematic points in the doc.
  • Add some basic tests for the class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/maps_test.cc

    r477 r684  
    2323#include <lemon/concepts/maps.h>
    2424#include <lemon/maps.h>
     25#include <lemon/list_graph.h>
    2526
    2627#include "test_tools.h"
     
    349350      check(v1[i++] == *it, "Something is wrong with LoggerBoolMap");
    350351  }
     352 
     353  // CrossRefMap
     354  {
     355    typedef ListDigraph Graph;
     356    DIGRAPH_TYPEDEFS(Graph);
     357
     358    checkConcept<ReadWriteMap<Node, int>,
     359                 CrossRefMap<Graph, Node, int> >();
     360   
     361    Graph gr;
     362    typedef CrossRefMap<Graph, Node, char> CRMap;
     363    typedef CRMap::ValueIterator ValueIt;
     364    CRMap map(gr);
     365   
     366    Node n0 = gr.addNode();
     367    Node n1 = gr.addNode();
     368    Node n2 = gr.addNode();
     369   
     370    map.set(n0, 'A');
     371    map.set(n1, 'B');
     372    map.set(n2, 'C');
     373    map.set(n2, 'A');
     374    map.set(n0, 'C');
     375
     376    check(map[n0] == 'C' && map[n1] == 'B' && map[n2] == 'A',
     377          "Wrong CrossRefMap");
     378    check(map('A') == n2 && map.inverse()['A'] == n2, "Wrong CrossRefMap");
     379    check(map('B') == n1 && map.inverse()['B'] == n1, "Wrong CrossRefMap");
     380    check(map('C') == n0 && map.inverse()['C'] == n0, "Wrong CrossRefMap");
     381
     382    ValueIt it = map.beginValue();
     383    check(*it++ == 'A' && *it++ == 'B' && *it++ == 'C' &&
     384          it == map.endValue(), "Wrong value iterator");
     385  }
    351386
    352387  return 0;
Note: See TracChangeset for help on using the changeset viewer.