deba@844: // -*- c++ -*- alpar@574: #ifndef HUGO_TEST_TEST_TOOLS_H alpar@574: #define HUGO_TEST_TEST_TOOLS_H alpar@574: alpar@574: //! \ingroup misc alpar@574: //! \file alpar@574: //! \brief Some utility to write test programs. alpar@574: alpar@574: alpar@574: #include alpar@574: #include alpar@574: alpar@679: ///If \c rc is fail, writes an error message end exit. alpar@574: alpar@574: ///If \c rc is fail, writes an error message end exit. alpar@574: ///The error message contains the file name and the line number of the alpar@679: ///source code in a standard from, which makes it possible to go there alpar@574: ///using good source browsers like e.g. \c emacs. alpar@574: /// alpar@574: ///For example alpar@574: ///\code check(0==1,"This is obviously false.");\endcode will alpar@574: ///print this (and then exits). alpar@574: ///\verbatim graph_test.cc:123: error: This is obviously false. \endverbatim alpar@774: /// alpar@774: ///\todo It should be in \c error.h alpar@574: #define check(rc, msg) \ alpar@574: if(!(rc)) { \ alpar@574: std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \ alpar@574: exit(1); \ alpar@574: } else { } \ alpar@574: alpar@574: ///Structure returned by \ref addPetersen(). alpar@574: alpar@574: ///Structure returned by \ref addPetersen(). alpar@574: /// alpar@574: template struct PetStruct alpar@574: { alpar@825: ///Vector containing the outer nodes. alpar@825: std::vector outer; alpar@825: ///Vector containing the inner nodes. alpar@825: std::vector inner; alpar@825: ///Vector containing the edges of the inner circle. alpar@825: std::vector incir; alpar@825: ///Vector containing the edges of the outer circle. alpar@825: std::vector outcir; alpar@825: ///Vector containing the chord edges. alpar@825: std::vector chords; alpar@574: }; alpar@574: alpar@721: alpar@721: alpar@574: ///Adds a Petersen graph to \c G. alpar@574: alpar@574: ///Adds a Petersen graph to \c G. alpar@825: ///\return The nodes end edges og the generated graph. alpar@721: alpar@721: template alpar@721: PetStruct addPetersen(Graph &G,int num=5) alpar@574: { alpar@574: PetStruct n; alpar@574: alpar@574: for(int i=0;i