From: g0dil Date: Wed, 23 Sep 2009 19:50:24 +0000 (+0000) Subject: Utils: Add SENF_CHECK_EQUAL_COLLECTIONS() unit-test for better char range support X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=309d78606f59617de0cfb1469b22111c846891ad;hp=8502d8b79fadfa53715dc9f62e1bee34435fadb9;p=senf.git Utils: Add SENF_CHECK_EQUAL_COLLECTIONS() unit-test for better char range support git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1436 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc index 380b696..15075bb 100644 --- a/senf/Packets/DefaultBundle/IPv6Extensions.test.cc +++ b/senf/Packets/DefaultBundle/IPv6Extensions.test.cc @@ -286,9 +286,9 @@ BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create) icmp->code() = 0u; ip.finalizeAll(); SENF_CHECK_NO_THROW( ip.dump(oss) ); - BOOST_CHECK_EQUAL_COLLECTIONS( - HopByHop_packetData, HopByHop_packetData+sizeof(HopByHop_packetData), - ip.data().begin(), ip.data().end() ); + SENF_CHECK_EQUAL_COLLECTIONS( + HopByHop_packetData, HopByHop_packetData+sizeof(HopByHop_packetData), + ip.data().begin(), ip.data().end() ); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/senf/Utils/auto_unit_test.hh b/senf/Utils/auto_unit_test.hh index c12bb7d..118f0de 100644 --- a/senf/Utils/auto_unit_test.hh +++ b/senf/Utils/auto_unit_test.hh @@ -41,6 +41,7 @@ #include //#include "auto_unit_test.mpp" +#include "auto_unit_test.ih" ///////////////////////////////hh.p//////////////////////////////////////// #if BOOST_VERSION >= 103400 @@ -94,6 +95,36 @@ try { expr ; } \ catch (std::exception & e) { std::cerr << e.what() << std::endl; throw; } ) +namespace senf { +namespace test { + + template + typename detail::NoCharIterator::type nocharIterator(Iterator i) + { return typename detail::NoCharIterator::type (i); } + + template + typename detail::NoCharIterator::type nocharIterator(Value * i) + { return typename detail::NoCharIterator::type (i); } + + template + typename detail::NoCharIterator::type nocharIterator(Value const * i) + { return typename detail::NoCharIterator::type (i); } + +}} + +/** \brief Check ranges for equality, writing char's as int's + + \ref SENF_CHECK_EQUAL_COLLECTIONS() is like \c BOOST_CHECK_EQUAL_COLLECTIONS(). The only + difference is, that \ref 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. + + \ingroup unittest + */ +#define SENF_CHECK_EQUAL_COLLECTIONS(a,b,c,d) \ + BOOST_CHECK_EQUAL_COLLECTIONS(senf::test::nocharIterator(a), senf::test::nocharIterator(b), \ + senf::test::nocharIterator(c), senf::test::nocharIterator(d)) + ///////////////////////////////hh.e//////////////////////////////////////// //#include "auto_unit_test.cci" //#include "auto_unit_test.ct" diff --git a/senf/Utils/auto_unit_test.ih b/senf/Utils/auto_unit_test.ih new file mode 100644 index 0000000..01283d6 --- /dev/null +++ b/senf/Utils/auto_unit_test.ih @@ -0,0 +1,79 @@ +// $Id$ +// +// Copyright (C) 2009 +// 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. +// +// 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. +// +// 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. + +/** \file + \brief auto_unit_test internal header */ + +#ifndef IH_SENF_senf_Utils_auto_unit_test_ +#define IH_SENF_senf_Utils_auto_unit_test_ 1 + +// Custom includes +#include +#include + +///////////////////////////////ih.p//////////////////////////////////////// + +namespace senf { +namespace test { +namespace detail { + + template + struct ConvertingIterator + : public boost::iterator_adaptor< + ConvertingIterator, Iterator, Type, boost::use_default, Type> + { + typedef boost::iterator_adaptor< + ConvertingIterator, Iterator, Type, boost::use_default, Type> Base; + ConvertingIterator(Iterator i) : Base (i) {} + }; + + template ::value_type> + struct NoCharIterator + { typedef Iterator type; }; + + template + struct NoCharIterator + { typedef ConvertingIterator type; }; + + template + struct NoCharIterator + { typedef ConvertingIterator type; }; + + template + struct NoCharIterator + { typedef ConvertingIterator type; }; + +}}} + +///////////////////////////////ih.e//////////////////////////////////////// +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: