From: g0dil Date: Wed, 6 Jun 2007 08:39:09 +0000 (+0000) Subject: Fix bug in SocketPolicy::checkBaseOf X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=a5afe330db009d6e22f87f25cb07485e87544299;p=senf.git Fix bug in SocketPolicy::checkBaseOf git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@252 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Socket/SocketPolicy.ct b/Socket/SocketPolicy.ct index bec4f71..db5ea1c 100644 --- a/Socket/SocketPolicy.ct +++ b/Socket/SocketPolicy.ct @@ -41,7 +41,7 @@ checkBaseOf(SocketPolicyBase const & other) // check, wether each policy of other is (dynamically!) convertible // to the corresponding (static) policy of this class. Throws // std::bad_cast on failure -# define SP_CheckPolicy(x1,x2,SomePolicy) (void) dynamic_cast(other.BOOST_PP_CAT(the,SomePolicy)()); +# define SP_CheckPolicy(x1,x2,SomePolicy) (void) dynamic_cast(other.BOOST_PP_CAT(the,SomePolicy)()); BOOST_PP_SEQ_FOR_EACH( SP_CheckPolicy, , SENF_SOCKET_POLICIES ) # undef SP_CheckPolicy } diff --git a/Socket/SocketPolicy.test.cc b/Socket/SocketPolicy.test.cc index 534f40d..83aa975 100644 --- a/Socket/SocketPolicy.test.cc +++ b/Socket/SocketPolicy.test.cc @@ -83,7 +83,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, @@ -122,12 +122,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 ); + BOOST_CHECK_NO_THROW( Policy3::checkBaseOf(p1) ); + } } ///////////////////////////////cc.e////////////////////////////////////////