// $Id$
//
-// Copyright (C) 2006
+// Copyright (C) 2006
// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
// Stefan Bund <stefan.bund@fokus.fraunhofer.de>
#include "SocketPolicy.hh"
#include "SocketPolicy.test.hh"
-#include <boost/test/auto_unit_test.hpp>
+#include "../Utils/auto_unit_test.hh"
#include <boost/test/test_tools.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/concept_check.hpp>
struct WritablePolicy : public WritePolicyBase {};
struct UnwritablePolicy : public WritePolicyBase {};
-
+
struct SocketBufferingPolicy : public BufferingPolicyBase {};
template <class Policy>
ConvertibleValue(ConvertibleValue const & other) {}
template <class OtherPolicy>
- ConvertibleValue(ConvertibleValue<OtherPolicy> const & other,
+ ConvertibleValue(ConvertibleValue<OtherPolicy> const & other,
typename boost::enable_if< SocketPolicyIsBaseOf<Policy,OtherPolicy> >::type * = 0)
{}
{ return *this; }
template <class OtherPolicy>
- typename boost::enable_if< SocketPolicyIsBaseOf<Policy,OtherPolicy>,
- ConvertibleValue >::type const &
+ typename boost::enable_if< SocketPolicyIsBaseOf<Policy,OtherPolicy>,
+ ConvertibleValue >::type const &
operator=(ConvertibleValue<OtherPolicy> const & other)
{ return *this; }
};
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,
ReadablePolicy,
UnspecifiedWritePolicy,
UnspecifiedBufferingPolicy> Policy2;
-
+
BOOST_MPL_ASSERT(( boost::is_same<Policy1,Policy2> ));
typedef MakeSocketPolicy<
// The following should fail at compile time
// BOOST_MPL_ASSERT(( SocketPolicyIsBaseOf<Policy1,Policy3> ));
-
- ConvertibleValue<Policy1> p1;
- ConvertibleValue<Policy3> p3(p1);
- p3 = p1;
- // The following should fail at compile time
- // p1 = p3;
+ {
+ ConvertibleValue<Policy1> p1;
+ ConvertibleValue<Policy3> 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 );
+ BOOST_CHECK_NO_THROW( Policy3::checkBaseOf(p1) );
+ }
}
///////////////////////////////cc.e////////////////////////////////////////
\f
// 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: