COIN-OR::LEMON - Graph Library

Changeset 171:02f4d5d9bfd7 in lemon-main for test/dfs_test.cc


Ignore:
Timestamp:
06/15/08 22:05:23 (16 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Children:
172:c94a80f38d7f, 173:b026e9779b28, 175:4eb8900a865c
Phase:
public
Message:

Improve and redesign test programs + unify their output (ticket #25)

  • Move graph related utilities form test_tools.h to graph_test.h.
  • Move the contents of graph_utils_test.h to graph_utils_test.cc.
  • Rename map_test.h -> graph_maps_test.h.
  • Rename digraph_test.h -> graph_test.h.
  • Many improvements in the following files:
    • digraph_test.cc
    • graph_test.cc
    • graph_test.h
    • graph_maps_test.h
    • graph_utils_test.cc
    • bfs_test.cc
    • dfs_test.cc
    • counter_test.cc
  • Test programs print messages only if it really seems necessary.
  • Remove \file commands form .cc test files.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/dfs_test.cc

    r100 r171  
    1717 */
    1818
    19 #include "test_tools.h"
    20 // #include <lemon/smart_graph.h>
     19#include <lemon/concepts/digraph.h>
     20#include <lemon/smart_graph.h>
    2121#include <lemon/list_graph.h>
    2222#include <lemon/dfs.h>
    2323#include <lemon/path.h>
    24 #include <lemon/concepts/digraph.h>
     24
     25#include "graph_test.h"
     26#include "test_tools.h"
    2527
    2628using namespace lemon;
    2729
    28 const int PET_SIZE =5;
    29 
    30 
    31 void check_Dfs_SmartDigraph_Compile()
     30void checkDfsCompile()
    3231{
    3332  typedef concepts::Digraph Digraph;
    34 
    35   typedef Digraph::Arc Arc;
    36   typedef Digraph::Node Node;
    37   typedef Digraph::ArcIt ArcIt;
    38   typedef Digraph::NodeIt NodeIt;
    39  
    4033  typedef Dfs<Digraph> DType;
    4134 
    4235  Digraph G;
    43   Node n;
    44   Arc e;
     36  Digraph::Node n;
     37  Digraph::Arc e;
    4538  int l;
    4639  bool b;
     
    6457}
    6558
    66 
    67 void check_Dfs_Function_Compile()
     59void checkDfsFunctionCompile()
    6860{
    6961  typedef int VType;
    7062  typedef concepts::Digraph Digraph;
    71 
    7263  typedef Digraph::Arc Arc;
    7364  typedef Digraph::Node Node;
    74   typedef Digraph::ArcIt ArcIt;
    75   typedef Digraph::NodeIt NodeIt;
    76   typedef concepts::ReadMap<Arc,VType> LengthMap;
    7765   
    7866  Digraph g;
     
    8472    .reachedMap(concepts::ReadWriteMap<Node,bool>())
    8573    .processedMap(concepts::WriteMap<Node,bool>())
    86     .run(Node());
    87  
     74    .run(Node());
    8875}
    8976
    90 int main()
    91 {
    92    
    93   // typedef SmartDigraph Digraph;
    94   typedef ListDigraph Digraph;
    95 
    96   typedef Digraph::Arc Arc;
    97   typedef Digraph::Node Node;
    98   typedef Digraph::ArcIt ArcIt;
    99   typedef Digraph::NodeIt NodeIt;
    100   typedef Digraph::ArcMap<int> LengthMap;
     77template <class Digraph>
     78void checkDfs() {
     79  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
    10180
    10281  Digraph G;
    10382  Node s, t;
    104   PetStruct<Digraph> ps = addPetersen(G,PET_SIZE);
     83  PetStruct<Digraph> ps = addPetersen(G, 5);
    10584   
    10685  s=ps.outer[2];
     
    11190 
    11291  Path<Digraph> p = dfs_test.path(t);
    113   check(p.length()==dfs_test.dist(t),"path() found a wrong path.");
     92  check(p.length() == dfs_test.dist(t),"path() found a wrong path.");
    11493  check(checkPath(G, p),"path() found a wrong path.");
    11594  check(pathSource(G, p) == s,"path() found a wrong path.");
     
    129108}
    130109
     110int main()
     111{
     112  checkDfs<ListDigraph>();
     113  checkDfs<SmartDigraph>();
     114  return 0;
     115}
Note: See TracChangeset for help on using the changeset viewer.