1.1 --- a/test/Makefile.am Tue Dec 18 12:52:45 2007 +0100
1.2 +++ b/test/Makefile.am Wed Dec 19 11:33:49 2007 +0000
1.3 @@ -1,9 +1,15 @@
1.4 EXTRA_DIST += \
1.5 test/Makefile
1.6
1.7 -noinst_HEADERS +=
1.8 -
1.9 -check_PROGRAMS +=
1.10 -
1.11 +noinst_HEADERS += \
1.12 + test/test_tools.h
1.13 +
1.14 +check_PROGRAMS += \
1.15 + test/test_tools_fail \
1.16 + test/test_tools_pass
1.17 +
1.18 TESTS += $(check_PROGRAMS)
1.19 XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
1.20 +
1.21 +test_test_tools_fail_SOURCES = test/test_tools_fail.cc
1.22 +test_test_tools_pass_SOURCES = test/test_tools_pass.cc
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/test/test_tools.h Wed Dec 19 11:33:49 2007 +0000
2.3 @@ -0,0 +1,48 @@
2.4 +/* -*- C++ -*-
2.5 + *
2.6 + * This file is a part of LEMON, a generic C++ optimization library
2.7 + *
2.8 + * Copyright (C) 2003-2007
2.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
2.11 + *
2.12 + * Permission to use, modify and distribute this software is granted
2.13 + * provided that this copyright notice appears in all copies. For
2.14 + * precise terms see the accompanying LICENSE file.
2.15 + *
2.16 + * This software is provided "AS IS" with no warranty of any kind,
2.17 + * express or implied, and with no claim as to its suitability for any
2.18 + * purpose.
2.19 + *
2.20 + */
2.21 +
2.22 +#ifndef LEMON_TEST_TEST_TOOLS_H
2.23 +#define LEMON_TEST_TEST_TOOLS_H
2.24 +
2.25 +#include <iostream>
2.26 +
2.27 +//! \ingroup misc
2.28 +//! \file
2.29 +//! \brief Some utilities to write test programs.
2.30 +
2.31 +
2.32 +///If \c rc is fail, writes an error message end exit.
2.33 +
2.34 +///If \c rc is fail, writes an error message end exit.
2.35 +///The error message contains the file name and the line number of the
2.36 +///source code in a standard from, which makes it possible to go there
2.37 +///using good source browsers like e.g. \c emacs.
2.38 +///
2.39 +///For example
2.40 +///\code check(0==1,"This is obviously false.");\endcode will
2.41 +///print this (and then exits).
2.42 +///\verbatim graph_test.cc:123: error: This is obviously false. \endverbatim
2.43 +///
2.44 +///\todo It should be in \c error.h
2.45 +#define check(rc, msg) \
2.46 + if(!(rc)) { \
2.47 + std::cerr << __FILE__ ":" << __LINE__ << ": error: " << msg << std::endl; \
2.48 + abort(); \
2.49 + } else { } \
2.50 +
2.51 +#endif
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/test/test_tools_fail.cc Wed Dec 19 11:33:49 2007 +0000
3.3 @@ -0,0 +1,25 @@
3.4 +/* -*- C++ -*-
3.5 + *
3.6 + * This file is a part of LEMON, a generic C++ optimization library
3.7 + *
3.8 + * Copyright (C) 2003-2007
3.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
3.11 + *
3.12 + * Permission to use, modify and distribute this software is granted
3.13 + * provided that this copyright notice appears in all copies. For
3.14 + * precise terms see the accompanying LICENSE file.
3.15 + *
3.16 + * This software is provided "AS IS" with no warranty of any kind,
3.17 + * express or implied, and with no claim as to its suitability for any
3.18 + * purpose.
3.19 + *
3.20 + */
3.21 +
3.22 +#include "test_tools.h"
3.23 +
3.24 +int main()
3.25 +{
3.26 + check(false, "Don't panic. Failing is the right behaviour here.");
3.27 + return 0;
3.28 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/test/test_tools_pass.cc Wed Dec 19 11:33:49 2007 +0000
4.3 @@ -0,0 +1,25 @@
4.4 +/* -*- C++ -*-
4.5 + *
4.6 + * This file is a part of LEMON, a generic C++ optimization library
4.7 + *
4.8 + * Copyright (C) 2003-2007
4.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
4.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
4.11 + *
4.12 + * Permission to use, modify and distribute this software is granted
4.13 + * provided that this copyright notice appears in all copies. For
4.14 + * precise terms see the accompanying LICENSE file.
4.15 + *
4.16 + * This software is provided "AS IS" with no warranty of any kind,
4.17 + * express or implied, and with no claim as to its suitability for any
4.18 + * purpose.
4.19 + *
4.20 + */
4.21 +
4.22 +#include "test_tools.h"
4.23 +
4.24 +int main()
4.25 +{
4.26 + check(true, "It should pass.");
4.27 + return 0;
4.28 +}