X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketPolicy.test.cc;h=2e70df938868e37106d288f43778456695f10c5c;hb=5443435c4c2b6e4386c5334b5b8358273f2bae93;hp=534f40d6e70ccd27bc3b46d572dc19a7a8a34323;hpb=85ab07d100a382467a42e19d741d403a7a96c951;p=senf.git diff --git a/Socket/SocketPolicy.test.cc b/Socket/SocketPolicy.test.cc index 534f40d..2e70df9 100644 --- a/Socket/SocketPolicy.test.cc +++ b/Socket/SocketPolicy.test.cc @@ -1,9 +1,9 @@ // $Id$ // // Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// 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 @@ -20,21 +20,22 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Unit tests +/** \file + \brief SocketPolicy unit tests */ -//#include "SocketPolicy.test.hh" +#include "SocketPolicy.test.hh" //#include "SocketPolicy.test.ih" // Custom includes -#include "SocketPolicy.hh" -#include "SocketPolicy.test.hh" - -#include -#include #include #include #include // enable_if +#include "SocketPolicy.hh" + +#include "../Utils/auto_unit_test.hh" +#include + #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -56,9 +57,7 @@ namespace { struct WritablePolicy : public WritePolicyBase {}; struct UnwritablePolicy : public WritePolicyBase {}; - struct SocketBufferingPolicy : public BufferingPolicyBase {}; - - template + template struct ConvertibleValue { ConvertibleValue() {} @@ -66,14 +65,14 @@ namespace { template ConvertibleValue(ConvertibleValue const & other, - typename boost::enable_if< SocketPolicyIsBaseOf >::type * = 0) + typename boost::enable_if< SocketPolicyIsBaseOf >::type * = 0) {} ConvertibleValue const & operator=(ConvertibleValue const & other) { return *this; } template - typename boost::enable_if< SocketPolicyIsBaseOf, + typename boost::enable_if< SocketPolicyIsBaseOf, ConvertibleValue >::type const & operator=(ConvertibleValue const & other) { return *this; } @@ -83,7 +82,7 @@ namespace { BOOST_AUTO_UNIT_TEST(socketPolicy) { - // All these checks are really compile-time checks ... + // Most of these checks are really compile-time checks ... typedef MakeSocketPolicy< UnixAddressingPolicy, @@ -95,8 +94,7 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) UnspecifiedFramingPolicy, ConnectedCommunicationPolicy, ReadablePolicy, - UnspecifiedWritePolicy, - UnspecifiedBufferingPolicy> Policy2; + UnspecifiedWritePolicy> Policy2; BOOST_MPL_ASSERT(( boost::is_same )); @@ -109,8 +107,7 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) UnspecifiedFramingPolicy, UnspecifiedCommunicationPolicy, ReadablePolicy, - UnspecifiedWritePolicy, - UnspecifiedBufferingPolicy> Policy4; + UnspecifiedWritePolicy> Policy4; BOOST_MPL_ASSERT(( boost::is_same )); BOOST_MPL_ASSERT_NOT(( boost::is_same )); @@ -122,12 +119,22 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) // The following should fail at compile time // BOOST_MPL_ASSERT(( SocketPolicyIsBaseOf )); - ConvertibleValue p1; - ConvertibleValue p3(p1); + { + ConvertibleValue p1; + ConvertibleValue p3(p1); + + p3 = p1; + // The following should fail at compile time + // p1 = p3; + } + + { + Policy1 p1; + Policy3 p3; - p3 = p1; - // The following should fail at compile time - // p1 = p3; + BOOST_CHECK_THROW( Policy1::checkBaseOf(p3), std::bad_cast ); + SENF_CHECK_NO_THROW( Policy3::checkBaseOf(p1) ); + } } ///////////////////////////////cc.e//////////////////////////////////////// @@ -140,4 +147,6 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: