alpar@906: /* -*- C++ -*- alpar@906: * src/test/test_tools.h - Part of HUGOlib, a generic C++ optimization library alpar@906: * alpar@906: * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@906: * (Egervary Combinatorial Optimization Research Group, EGRES). alpar@906: * alpar@906: * Permission to use, modify and distribute this software is granted alpar@906: * provided that this copyright notice appears in all copies. For alpar@906: * precise terms see the accompanying LICENSE file. alpar@906: * alpar@906: * This software is provided "AS IS" with no warranty of any kind, alpar@906: * express or implied, and with no claim as to its suitability for any alpar@906: * purpose. alpar@906: * alpar@906: */ alpar@906: 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. deba@909: ///\return The nodes and edges of 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 struct SymPetStruct deba@909: { deba@909: ///Vector containing the outer nodes. deba@909: std::vector outer; deba@909: ///Vector containing the inner nodes. deba@909: std::vector inner; deba@909: ///Vector containing the edges of the inner circle. deba@909: std::vector incir; deba@909: ///Vector containing the edges of the outer circle. deba@909: std::vector outcir; deba@909: ///Vector containing the chord edges. deba@909: std::vector chords; deba@909: }; deba@909: deba@909: ///Adds a Petersen graph to the symmetric \c G. deba@909: deba@909: ///Adds a Petersen graph to the symmetric \c G. deba@909: ///\return The nodes and edges of the generated graph. deba@909: deba@909: template deba@909: SymPetStruct addSymPetersen(Graph &G,int num=5) deba@909: { deba@909: SymPetStruct n; deba@909: deba@909: for(int i=0;i