COIN-OR::LEMON - Graph Library

Changeset 171:02f4d5d9bfd7 in lemon-main for test/bfs_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/bfs_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/bfs.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_Bfs_Compile()
     30void checkBfsCompile()
    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 Bfs<Digraph> BType;
    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 void check_Bfs_Function_Compile()
     59void checkBfsFunctionCompile()
    6760{
    6861  typedef int VType;
    6962  typedef concepts::Digraph Digraph;
    70 
    7163  typedef Digraph::Arc Arc;
    7264  typedef Digraph::Node Node;
    73   typedef Digraph::ArcIt ArcIt;
    74   typedef Digraph::NodeIt NodeIt;
    75   typedef concepts::ReadMap<Arc,VType> LengthMap;
    7665   
    7766  Digraph g;
     
    8473    .processedMap(concepts::WriteMap<Node,bool>())
    8574    .run(Node());
    86  
    8775}
    8876
    89 int main()
    90 {
    91    
    92   // typedef SmartDigraph Digraph;
    93   typedef ListDigraph Digraph;
    94 
    95   typedef Digraph::Arc Arc;
    96   typedef Digraph::Node Node;
    97   typedef Digraph::ArcIt ArcIt;
    98   typedef Digraph::NodeIt NodeIt;
    99   typedef Digraph::ArcMap<int> LengthMap;
     77template <class Digraph>
     78void checkBfs() {
     79  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
    10080
    10181  Digraph G;
    10282  Node s, t;
    103   PetStruct<Digraph> ps = addPetersen(G,PET_SIZE);
     83  PetStruct<Digraph> ps = addPetersen(G, 5);
    10484   
    10585  s=ps.outer[2];
     
    10989  bfs_test.run(s);
    11090 
    111   check(bfs_test.dist(t)==3,"Bfs found a wrong path. " << bfs_test.dist(t));
     91  check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t));
    11292
    11393  Path<Digraph> p = bfs_test.path(t);
    114   check(p.length()==3,"getPath() found a wrong path.");
     94  check(p.length()==3,"path() found a wrong path.");
    11595  check(checkPath(G, p),"path() found a wrong path.");
    11696  check(pathSource(G, p) == s,"path() found a wrong path.");
     
    140120}
    141121
     122int main()
     123{
     124  checkBfs<ListDigraph>();
     125  checkBfs<SmartDigraph>();
     126  return 0;
     127}
Note: See TracChangeset for help on using the changeset viewer.