X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2Fauto_unit_test.hh;h=de6966bcdf4bc744b4e7506097d9398a455fc10f;hb=refs%2Fheads%2Fmaster;hp=c12bb7d90e7c8d41e52fbe306703dfc8408ee5ce;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Utils/auto_unit_test.hh b/senf/Utils/auto_unit_test.hh index c12bb7d..de6966b 100644 --- a/senf/Utils/auto_unit_test.hh +++ b/senf/Utils/auto_unit_test.hh @@ -2,23 +2,28 @@ // // Copyright (C) 2007 // Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY -// Stefan Bund // -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. +// The contents of this file are subject to the Fraunhofer FOKUS Public License +// Version 1.0 (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// http://senf.berlios.de/license.html // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. +// The Fraunhofer FOKUS Public License Version 1.0 is based on, +// but modifies the Mozilla Public License Version 1.1. +// See the full license text for the amendments. // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// Software distributed under the License is distributed on an "AS IS" basis, +// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +// for the specific language governing rights and limitations under the License. +// +// The Original Code is Fraunhofer FOKUS code. +// +// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. +// (registered association), Hansastraße 27 c, 80686 Munich, Germany. +// All Rights Reserved. +// +// Contributor(s): +// Stefan Bund /** \file \brief Boost.Test auto unit test compatibility across Boost V 1.33 and 1.34 @@ -41,7 +46,8 @@ #include //#include "auto_unit_test.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +#include "auto_unit_test.ih" +//-///////////////////////////////////////////////////////////////////////////////////////////////// #if BOOST_VERSION >= 103400 @@ -58,8 +64,8 @@ /** \brief Check for compile failure - COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile time - failure. + \c COMPILE_FAIL() is used to check, that a certain piece of code will produce a compile + time failure. \code #ifdef COMPILE_CHECK @@ -69,7 +75,7 @@ // fails to compile .... int x = "foo"; } - + COMPILE_FAIL(bar) { ... } @@ -77,27 +83,90 @@ \endcode This check is performed by the extended unit-test builder in \c senfscons. - + \ingroup unittest */ #define COMPILE_FAIL(n) void n() /** \brief Show exception information - \ref SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the + \c SENF_CHECK_NO_THROW() is an extension to \c BOOST_CHECK_NO_THROW() which will write out the unabridged exception information when an exception is thrown in addition to signaling an error. \ingroup unittest */ -#define SENF_CHECK_NO_THROW(expr) \ - BOOST_CHECK_NO_THROW( \ - try { expr ; } \ +#define SENF_CHECK_NO_THROW(expr) \ + BOOST_CHECK_NO_THROW( \ + try { expr ; } \ catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } ) -///////////////////////////////hh.e//////////////////////////////////////// +namespace senf { +namespace test { + + template + typename detail::NoCharIterator::type nocharIterator(Iterator i); + +}} + +/** \brief Check ranges for equality, writing char's as int's + + \c SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only + difference is, that \c SENF_CHECK_EQUAL_COLLECTIONS() will write out collection values in + numeric form (and not as single characters) if the elements are of any char type. Other types + are not affected. + + \hideinitializer + \ingroup unittest + */ +#define SENF_CHECK_EQUAL_COLLECTIONS(left_begin, left_end, right_begin, right_end) \ + BOOST_CHECK_EQUAL_COLLECTIONS( \ + senf::test::nocharIterator(left_begin), senf::test::nocharIterator(left_end), \ + senf::test::nocharIterator(right_begin), senf::test::nocharIterator(right_end)) + +/** \brief Define new test case + + \c SENF_AUTO_UNIT_TEST() is like \c BOOST_AUTO_UNIT_TEST(). The only difference is, that + if an exception is thrown in the test case \c SENF_AUTO_UNIT_TEST() will write out the + complete what-message of the exception. + + \hideinitializer + \ingroup unittest + */ +#define SENF_AUTO_UNIT_TEST(name) \ + void senf_test_body_##name(); \ + BOOST_AUTO_UNIT_TEST(name) \ + { \ + try { \ + senf_test_body_##name(); \ + } \ + catch (std::exception & e) { \ + std::cerr << e.what() << std::endl; \ + throw; \ + } \ + } \ + void senf_test_body_##name() + + +#ifdef DOXYGEN + /** \brief Check for non-equality + + \c SENF_CHECK_NOT_EQUAL() is the opposite of \c BOOST_CHECK_EQUAL. + \hideinitializer + \ingroup unittest + */ + #define SENF_CHECK_NOT_EQUAL( Left, Rigth) +#else +#ifdef BOOST_CHECK_NE + #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK_NE( Left, Right) +#else + #define SENF_CHECK_NOT_EQUAL( Left, Right) BOOST_CHECK( Left != Right) +#endif +#endif + +//-///////////////////////////////////////////////////////////////////////////////////////////////// //#include "auto_unit_test.cci" //#include "auto_unit_test.ct" -//#include "auto_unit_test.cti" +#include "auto_unit_test.cti" #endif