2 #ifndef HUGO_TEST_TEST_TOOLS_H
3 #define HUGO_TEST_TEST_TOOLS_H
7 //! \brief Some utility to write test programs.
13 ///If \c rc is fail, writes an error message end exit.
15 ///If \c rc is fail, writes an error message end exit.
16 ///The error message contains the file name and the line number of the
17 ///source code in a standard from, which makes it possible to go there
18 ///using good source browsers like e.g. \c emacs.
21 ///\code check(0==1,"This is obviously false.");\endcode will
22 ///print this (and then exits).
23 ///\verbatim graph_test.cc:123: error: This is obviously false. \endverbatim
25 ///\todo It should be in \c error.h
26 #define check(rc, msg) \
28 std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
32 ///Structure returned by \ref addPetersen().
34 ///Structure returned by \ref addPetersen().
36 template<class Graph> struct PetStruct
38 ///Vector containing the outer nodes.
39 std::vector<typename Graph::Node> outer;
40 ///Vector containing the inner nodes.
41 std::vector<typename Graph::Node> inner;
42 ///Vector containing the edges of the inner circle.
43 std::vector<typename Graph::Edge> incir;
44 ///Vector containing the edges of the outer circle.
45 std::vector<typename Graph::Edge> outcir;
46 ///Vector containing the chord edges.
47 std::vector<typename Graph::Edge> chords;
52 ///Adds a Petersen graph to \c G.
54 ///Adds a Petersen graph to \c G.
55 ///\return The nodes end edges og the generated graph.
57 template<typename Graph>
58 PetStruct<Graph> addPetersen(Graph &G,int num=5)
62 for(int i=0;i<num;i++) {
63 n.outer.push_back(G.addNode());
64 n.inner.push_back(G.addNode());
67 for(int i=0;i<num;i++) {
68 n.chords.push_back(G.addEdge(n.outer[i],n.inner[i]));
69 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%5]));
70 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5]));