PPI: Checkin of first compiling (yet not working) version
[senf.git] / Socket / FileHandle.test.cc
index c86a26b..f4dac9d 100644 (file)
@@ -1,6 +1,6 @@
 // $Id$
 //
-// Copyright (C) 2006 
+// Copyright (C) 2006
 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
 ///////////////////////////////cc.p////////////////////////////////////////
 
 namespace {
-    class FHandle : public satcom::lib::FileHandle
+    class FHandle : public senf::FileHandle
     {
     public:
-        FHandle(int fd=-1) 
-            : satcom::lib::FileHandle(std::auto_ptr<satcom::lib::FileBody>(
-                                          new satcom::lib::FileBody(fd))) {}
-        FHandle(std::string name) 
-            : satcom::lib::FileHandle(std::auto_ptr<satcom::lib::FileBody>(
-                                          new satcom::lib::FileBody()))
+        FHandle() {}
+        FHandle(int fd)
+            : senf::FileHandle(std::auto_ptr<senf::FileBody>(
+                                          new senf::FileBody(fd))) {}
+        FHandle(std::string const & name)
+            : senf::FileHandle(std::auto_ptr<senf::FileBody>(
+                                          new senf::FileBody()))
             {
                 int rv = ::open(name.c_str(),O_RDWR|O_NONBLOCK) ;
                 if (rv<0)
-                    throw satcom::lib::SystemException(errno);
+                    throw senf::SystemException(errno);
                 fd(rv);
             }
     };
@@ -66,15 +67,17 @@ BOOST_AUTO_UNIT_TEST(fileHandle)
             BOOST_CHECK(fh);
             BOOST_CHECK(!!fh);
 
-            FHandle fh2(fh);
+            FHandle fh2;
+            BOOST_CHECK( ! fh2.valid() );
+            fh2 = fh;
             BOOST_CHECK_EQUAL(fh.fd(), fh2.fd());
-            
+
             BOOST_CHECK(fh.writeable());
             BOOST_CHECK_NO_THROW(fh.close());
-            BOOST_CHECK_THROW(fh.close(),satcom::lib::SystemException);
+            BOOST_CHECK_THROW(fh.close(),senf::SystemException);
             BOOST_CHECK_NO_THROW(fh.terminate());
         }
-        
+
         {
             FHandle fh("/dev/zero");
             BOOST_CHECK(fh.readable());
@@ -104,12 +107,17 @@ BOOST_AUTO_UNIT_TEST(fileHandle)
         BOOST_FAIL(ex.what());
     }
 }
-    
+
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
 \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: