alpar@209: /* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@4:  *
alpar@209:  * This file is a part of LEMON, a generic C++ optimization library.
alpar@4:  *
alpar@440:  * Copyright (C) 2003-2009
alpar@4:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@4:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@4:  *
alpar@4:  * Permission to use, modify and distribute this software is granted
alpar@4:  * provided that this copyright notice appears in all copies. For
alpar@4:  * precise terms see the accompanying LICENSE file.
alpar@4:  *
alpar@4:  * This software is provided "AS IS" with no warranty of any kind,
alpar@4:  * express or implied, and with no claim as to its suitability for any
alpar@4:  * purpose.
alpar@4:  *
alpar@4:  */
alpar@4: 
alpar@4: #ifndef LEMON_TEST_TEST_TOOLS_H
alpar@4: #define LEMON_TEST_TEST_TOOLS_H
alpar@4: 
kpeter@171: ///\ingroup misc
kpeter@171: ///\file
kpeter@171: ///\brief Some utilities to write test programs.
kpeter@171: 
alpar@4: #include <iostream>
alpar@184: #include <stdlib.h>
alpar@100: 
kpeter@171: ///If \c rc is fail, writes an error message and exits.
alpar@100: 
kpeter@171: ///If \c rc is fail, writes an error message and exits.
alpar@4: ///The error message contains the file name and the line number of the
alpar@4: ///source code in a standard from, which makes it possible to go there
alpar@4: ///using good source browsers like e.g. \c emacs.
alpar@4: ///
alpar@4: ///For example
alpar@4: ///\code check(0==1,"This is obviously false.");\endcode will
kpeter@171: ///print something like this (and then exits).
kpeter@171: ///\verbatim file_name.cc:123: error: This is obviously false. \endverbatim
alpar@4: #define check(rc, msg) \
alpar@4:   if(!(rc)) { \
alpar@4:     std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
alpar@4:     abort(); \
alpar@4:   } else { } \
alpar@4: 
alpar@4: #endif