4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Boost.Test auto unit test compatibility across Boost V 1.33 and 1.34
31 This header file will allows to consistently use the Boost Version 1.33 syntax for defining auto
32 unit tests. If the available Boost version is 1.34, this file will automatically take care of
33 any necessary workarounds.
35 So, instead of <tt>\#include <boost/test/auto_unit_test.hpp></tt>, you should always write
37 \#include "../Utils/auto_unit_test.hh"
38 </pre> (with possibliy adjusted path).
41 #ifndef HH_SENF_Utils_auto_unit_test_
42 #define HH_SENF_Utils_auto_unit_test_ 1
46 #include <boost/version.hpp>
48 //#include "auto_unit_test.mpp"
49 #include "auto_unit_test.ih"
50 //-/////////////////////////////////////////////////////////////////////////////////////////////////
52 #if BOOST_VERSION >= 103400
54 # define BOOST_AUTO_UNIT_TEST BOOST_AUTO_TEST_CASE
58 #include <boost/test/auto_unit_test.hpp>
60 /** \defgroup unittest Boost.Test extensions
62 This module defines some additional extensions to Boost.Test
65 /** \brief Check for compile failure
67 \c COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile
75 // fails to compile ....
85 This check is performed by the extended unit-test builder in \c senfscons.
89 #define COMPILE_FAIL(n) void n()
91 /** \brief Show exception information
93 \c SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the
94 unabridged exception information when an exception is thrown in addition to signaling an error.
98 #define SENF_CHECK_NO_THROW(expr) \
99 BOOST_CHECK_NO_THROW( \
101 catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } )
106 template <class Iterator>
107 typename detail::NoCharIterator<Iterator>::type nocharIterator(Iterator i);
111 /** \brief Check ranges for equality, writing char's as int's
113 \c SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only
114 difference is, that \c SENF_CHECK_EQUAL_COLLECTIONS() will write out collection values in
115 numeric form (and not as single characters) if the elements are of any char type. Other types
121 #define SENF_CHECK_EQUAL_COLLECTIONS(left_begin, left_end, right_begin, right_end) \
122 BOOST_CHECK_EQUAL_COLLECTIONS( \
123 senf::test::nocharIterator(left_begin), senf::test::nocharIterator(left_end), \
124 senf::test::nocharIterator(right_begin), senf::test::nocharIterator(right_end))
126 /** \brief Define new test case
128 \c SENF_AUTO_UNIT_TEST() is like \c BOOST_AUTO_UNIT_TEST(). The only difference is, that
129 if an exception is thrown in the test case \c SENF_AUTO_UNIT_TEST() will write out the
130 complete what-message of the exception.
135 #define SENF_AUTO_UNIT_TEST(name) \
136 void senf_test_body_##name(); \
137 BOOST_AUTO_UNIT_TEST(name) \
140 senf_test_body_##name(); \
142 catch (std::exception & e) { \
143 std::cerr << e.what() << std::endl; \
147 void senf_test_body_##name()
151 /** \brief Check for non-equality
153 \c SENF_CHECK_NOT_EQUAL() is the opposite of \c BOOST_CHECK_EQUAL.
157 #define SENF_CHECK_NOT_EQUAL( Left, Rigth)
159 #ifdef BOOST_CHECK_NE
160 #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK_NE( Left, Right)
162 #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK( Left != Right)
166 //-/////////////////////////////////////////////////////////////////////////////////////////////////
167 //#include "auto_unit_test.cci"
168 //#include "auto_unit_test.ct"
169 #include "auto_unit_test.cti"
176 // comment-column: 40
177 // c-file-style: "senf"
178 // indent-tabs-mode: nil
179 // ispell-local-dictionary: "american"
180 // compile-command: "scons -u test"