Merged revisions 570-572,574-575,578-579,581-595,598-611 via svnmerge from
[senf.git] / Socket / SocketPolicy.test.cc
index af167a4..0a99bdf 100644 (file)
@@ -1,9 +1,9 @@
 // $Id$
 //
-// Copyright (C) 2006 
-// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
-// Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
-//     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
+// Copyright (C) 2006
+// Fraunhofer Institute for Open Communication Systems (FOKUS) 
+// Competence Center NETwork research (NET), St. Augustin, GERMANY 
+//     Stefan Bund <g0dil@berlios.de>
 //
 // 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 <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>
@@ -38,7 +38,7 @@
 #define prefix_
 ///////////////////////////////cc.p////////////////////////////////////////
 
-using namespace satcom::lib;
+using namespace senf;
 
 namespace {
     struct INetAddressingPolicy : public AddressingPolicyBase {};
@@ -55,8 +55,6 @@ namespace {
 
     struct WritablePolicy : public WritePolicyBase {};
     struct UnwritablePolicy : public WritePolicyBase {};
-    
-    struct SocketBufferingPolicy : public BufferingPolicyBase {};
 
     template <class Policy>
     struct ConvertibleValue
@@ -65,7 +63,7 @@ namespace {
         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)
             {}
 
@@ -73,8 +71,8 @@ namespace {
             { 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; }
     };
@@ -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<Policy1,Policy2> ));
 
     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<Policy3,Policy4> ));
     BOOST_MPL_ASSERT_NOT(( boost::is_same<Policy1, Policy3> ));
@@ -121,13 +117,23 @@ BOOST_AUTO_UNIT_TEST(socketPolicy)
 
     // 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////////////////////////////////////////
@@ -136,5 +142,10 @@ BOOST_AUTO_UNIT_TEST(socketPolicy)
 \f
 // Local Variables:
 // mode: c++
-// c-file-style: "satcom"
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
 // End: