1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/test_tools.h Wed Dec 19 11:33:49 2007 +0000
1.3 @@ -0,0 +1,48 @@
1.4 +/* -*- C++ -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library
1.7 + *
1.8 + * Copyright (C) 2003-2007
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#ifndef LEMON_TEST_TEST_TOOLS_H
1.23 +#define LEMON_TEST_TEST_TOOLS_H
1.24 +
1.25 +#include <iostream>
1.26 +
1.27 +//! \ingroup misc
1.28 +//! \file
1.29 +//! \brief Some utilities to write test programs.
1.30 +
1.31 +
1.32 +///If \c rc is fail, writes an error message end exit.
1.33 +
1.34 +///If \c rc is fail, writes an error message end exit.
1.35 +///The error message contains the file name and the line number of the
1.36 +///source code in a standard from, which makes it possible to go there
1.37 +///using good source browsers like e.g. \c emacs.
1.38 +///
1.39 +///For example
1.40 +///\code check(0==1,"This is obviously false.");\endcode will
1.41 +///print this (and then exits).
1.42 +///\verbatim graph_test.cc:123: error: This is obviously false. \endverbatim
1.43 +///
1.44 +///\todo It should be in \c error.h
1.45 +#define check(rc, msg) \
1.46 + if(!(rc)) { \
1.47 + std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
1.48 + abort(); \
1.49 + } else { } \
1.50 +
1.51 +#endif