COIN-OR::LEMON - Graph Library

Ticket #371: 371-test-99be8c4f5a60.patch

File 371-test-99be8c4f5a60.patch, 2.5 KB (added by Peter Kovacs, 14 years ago)
  • test/graph_copy_test.cc

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1277214034 -7200
    # Node ID 99be8c4f5a602489a41010e536400a6606120061
    # Parent  50446fbc0602435ce6d92911272a07c3b61286cf
    Extend graph_copy_test.cc (#371)
    
    diff --git a/test/graph_copy_test.cc b/test/graph_copy_test.cc
    a b  
    2929void digraph_copy_test() {
    3030  const int nn = 10;
    3131
     32  // Build a digraph
    3233  SmartDigraph from;
    3334  SmartDigraph::NodeMap<int> fnm(from);
    3435  SmartDigraph::ArcMap<int> fam(from);
     
    5152    }
    5253  }
    5354
     55  // Test digraph copy
    5456  ListDigraph to;
    5557  ListDigraph::NodeMap<int> tnm(to);
    5658  ListDigraph::ArcMap<int> tam(to);
     
    6870    nodeRef(nr).arcRef(er).
    6971    nodeCrossRef(ncr).arcCrossRef(ecr).
    7072    node(fn, tn).arc(fa, ta).run();
     73 
     74  check(countNodes(from) == countNodes(to), "Wrong copy.");
     75  check(countArcs(from) == countArcs(to), "Wrong copy.");
    7176
    7277  for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
    7378    check(ncr[nr[it]] == it, "Wrong copy.");
     
    9095  }
    9196  check(tn == nr[fn], "Wrong copy.");
    9297  check(ta == er[fa], "Wrong copy.");
     98
     99  // Test repeated copy
     100  digraphCopy(from, to).run();
     101 
     102  check(countNodes(from) == countNodes(to), "Wrong copy.");
     103  check(countArcs(from) == countArcs(to), "Wrong copy.");
    93104}
    94105
    95106void graph_copy_test() {
    96107  const int nn = 10;
    97108
     109  // Build a graph
    98110  SmartGraph from;
    99111  SmartGraph::NodeMap<int> fnm(from);
    100112  SmartGraph::ArcMap<int> fam(from);
     
    122134    }
    123135  }
    124136
     137  // Test graph copy
    125138  ListGraph to;
    126139  ListGraph::NodeMap<int> tnm(to);
    127140  ListGraph::ArcMap<int> tam(to);
     
    144157    nodeCrossRef(ncr).arcCrossRef(acr).edgeCrossRef(ecr).
    145158    node(fn, tn).arc(fa, ta).edge(fe, te).run();
    146159
     160  check(countNodes(from) == countNodes(to), "Wrong copy.");
     161  check(countEdges(from) == countEdges(to), "Wrong copy.");
     162  check(countArcs(from) == countArcs(to), "Wrong copy.");
     163
    147164  for (SmartGraph::NodeIt it(from); it != INVALID; ++it) {
    148165    check(ncr[nr[it]] == it, "Wrong copy.");
    149166    check(fnm[it] == tnm[nr[it]], "Wrong copy.");
     
    180197  check(tn == nr[fn], "Wrong copy.");
    181198  check(ta == ar[fa], "Wrong copy.");
    182199  check(te == er[fe], "Wrong copy.");
     200
     201  // Test repeated copy
     202  graphCopy(from, to).run();
     203 
     204  check(countNodes(from) == countNodes(to), "Wrong copy.");
     205  check(countEdges(from) == countEdges(to), "Wrong copy.");
     206  check(countArcs(from) == countArcs(to), "Wrong copy.");
    183207}
    184208
    185209