X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FSocketPolicy.test.cc;h=72ba433a6d65a7a574edaf99147d7596d6f6ebac;hb=9428e2877c15dac640efdb075d40cafea554cc88;hp=5b7aeb05bb554cb4ecde6f3300b5a6fd09829d1d;hpb=ac6a813d9d99f7add4e13aff7a4bcd314d5604a6;p=senf.git diff --git a/Socket/SocketPolicy.test.cc b/Socket/SocketPolicy.test.cc index 5b7aeb0..72ba433 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 +// Copyright (C) 2006 +// 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 @@ -29,7 +29,7 @@ #include "SocketPolicy.hh" #include "SocketPolicy.test.hh" -#include +#include "../Utils/auto_unit_test.hh" #include #include #include @@ -55,26 +55,24 @@ namespace { struct WritablePolicy : public WritePolicyBase {}; struct UnwritablePolicy : public WritePolicyBase {}; - - struct SocketBufferingPolicy : public BufferingPolicyBase {}; - template + template struct ConvertibleValue { ConvertibleValue() {} ConvertibleValue(ConvertibleValue const & other) {} template - ConvertibleValue(ConvertibleValue const & other, - typename boost::enable_if< SocketPolicyIsBaseOf >::type * = 0) + ConvertibleValue(ConvertibleValue const & other, + typename boost::enable_if< SocketPolicyIsBaseOf >::type * = 0) {} ConvertibleValue const & operator=(ConvertibleValue const & other) { return *this; } template - typename boost::enable_if< SocketPolicyIsBaseOf, - ConvertibleValue >::type const & + typename boost::enable_if< SocketPolicyIsBaseOf, + ConvertibleValue >::type const & operator=(ConvertibleValue const & other) { return *this; } }; @@ -83,7 +81,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,9 +93,8 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) UnspecifiedFramingPolicy, ConnectedCommunicationPolicy, ReadablePolicy, - UnspecifiedWritePolicy, - UnspecifiedBufferingPolicy> Policy2; - + UnspecifiedWritePolicy> Policy2; + BOOST_MPL_ASSERT(( boost::is_same )); typedef MakeSocketPolicy< @@ -109,8 +106,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 )); @@ -121,13 +117,23 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) // The following should fail at compile time // BOOST_MPL_ASSERT(( SocketPolicyIsBaseOf )); - - ConvertibleValue p1; - ConvertibleValue p3(p1); - p3 = p1; - // The following should fail at compile time - // p1 = p3; + { + ConvertibleValue p1; + ConvertibleValue p3(p1); + + p3 = p1; + // The following should fail at compile time + // p1 = p3; + } + + { + Policy1 p1; + Policy3 p3; + + BOOST_CHECK_THROW( Policy1::checkBaseOf(p3), std::bad_cast ); + SENF_CHECK_NO_THROW( Policy3::checkBaseOf(p1) ); + } } ///////////////////////////////cc.e//////////////////////////////////////// @@ -136,5 +142,10 @@ BOOST_AUTO_UNIT_TEST(socketPolicy) // Local Variables: // mode: c++ +// fill-column: 100 // c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 // End: