4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Boost.Test auto unit test compatibility across Boost V 1.33 and 1.34
26 This header file will allows to consistently use the Boost Version 1.33 syntax for defining auto
27 unit tests. If the available Boost version is 1.34, this file will automatically take care of
28 any necessary workarounds.
30 So, instead of <tt>\#include <boost/test/auto_unit_test.hpp></tt>, you should always write
32 \#include "../Utils/auto_unit_test.hh"
33 </pre> (with possibliy adjusted path).
36 #ifndef HH_SENF_Utils_auto_unit_test_
37 #define HH_SENF_Utils_auto_unit_test_ 1
41 #include <boost/version.hpp>
43 //#include "auto_unit_test.mpp"
44 #include "auto_unit_test.ih"
45 ///////////////////////////////hh.p////////////////////////////////////////
47 #if BOOST_VERSION >= 103400
49 # define BOOST_AUTO_UNIT_TEST BOOST_AUTO_TEST_CASE
53 #include <boost/test/auto_unit_test.hpp>
55 /** \defgroup unittest Boost.Test extensions
57 This module defines some additional extensions to Boost.Test
60 /** \brief Check for compile failure
62 \c COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile
70 // fails to compile ....
80 This check is performed by the extended unit-test builder in \c senfscons.
84 #define COMPILE_FAIL(n) void n()
86 /** \brief Show exception information
88 \c SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the
89 unabridged exception information when an exception is thrown in addition to signaling an error.
93 #define SENF_CHECK_NO_THROW(expr) \
94 BOOST_CHECK_NO_THROW( \
96 catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } )
101 template <class Iterator>
102 typename detail::NoCharIterator<Iterator>::type nocharIterator(Iterator i);
106 /** \brief Check ranges for equality, writing char's as int's
108 \c SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only
109 difference is, that \c SENF_CHECK_EQUAL_COLLECTIONS() will write out collection values in
110 numeric form (and not as single characters) if the elements are of any char type. Other types
116 #define SENF_CHECK_EQUAL_COLLECTIONS(left_begin, left_end, right_begin, right_end) \
117 BOOST_CHECK_EQUAL_COLLECTIONS( \
118 senf::test::nocharIterator(left_begin), senf::test::nocharIterator(left_end), \
119 senf::test::nocharIterator(right_begin), senf::test::nocharIterator(right_end))
121 /** \brief Define new test case
123 \c SENF_AUTO_UNIT_TEST() is like \c BOOST_AUTO_UNIT_TEST(). The only difference is, that
124 if an exception is thrown in the test case \c SENF_AUTO_UNIT_TEST() will write out the
125 complete what-message of the exception.
130 #define SENF_AUTO_UNIT_TEST(name) \
131 void senf_test_body_##name(); \
132 BOOST_AUTO_UNIT_TEST(name) \
135 senf_test_body_##name(); \
137 catch (std::exception & e) { \
138 std::cerr << e.what() << std::endl; \
142 void senf_test_body_##name()
146 /** \brief Check for non-equality
148 \c SENF_CHECK_NOT_EQUAL() is the opposite of \c BOOST_CHECK_EQUAL.
152 #define SENF_CHECK_NOT_EQUAL( Left, Rigth)
154 #ifdef BOOST_CHECK_NE
155 #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK_NE( Left, Right)
157 #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK( Left != Right)
161 ///////////////////////////////hh.e////////////////////////////////////////
162 //#include "auto_unit_test.cci"
163 //#include "auto_unit_test.ct"
164 #include "auto_unit_test.cti"
171 // comment-column: 40
172 // c-file-style: "senf"
173 // indent-tabs-mode: nil
174 // ispell-local-dictionary: "american"
175 // compile-command: "scons -u test"