X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Socket%2FFileHandle.test.cc;h=60ba3ba60eab29eee968cede0ff5cac933db3532;hb=532240d72e09e19e57fac9bb55c2560b9c9e5b97;hp=c86a26b99aadefa1823be4e7e6e447f00bc31b63;hpb=c52cd7d87dbb525c1267aad27391b8b7365dbb57;p=senf.git diff --git a/Socket/FileHandle.test.cc b/Socket/FileHandle.test.cc index c86a26b..60ba3ba 100644 --- a/Socket/FileHandle.test.cc +++ b/Socket/FileHandle.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 @@ -20,7 +20,8 @@ // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// Unit tests +/** \file + \brief FileHandle unit tests */ //#include "FileHandle.test.hh" //#include "FileHandle.test.ih" @@ -31,26 +32,27 @@ #include #include "FileHandle.hh" -#include +#include "../Utils/auto_unit_test.hh" #include #define prefix_ ///////////////////////////////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( - new satcom::lib::FileBody(fd))) {} - FHandle(std::string name) - : satcom::lib::FileHandle(std::auto_ptr( - new satcom::lib::FileBody())) + FHandle() {} + FHandle(int fd) + : senf::FileHandle(std::auto_ptr( + new senf::FileBody(fd))) {} + FHandle(std::string const & name) + : senf::FileHandle(std::auto_ptr( + new senf::FileBody())) { int rv = ::open(name.c_str(),O_RDWR|O_NONBLOCK) ; if (rv<0) - throw satcom::lib::SystemException(errno); + throw senf::SystemException(); fd(rv); } }; @@ -66,15 +68,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_NO_THROW(fh.terminate()); + SENF_CHECK_NO_THROW(fh.close()); + BOOST_CHECK_THROW(fh.close(),senf::SystemException); + SENF_CHECK_NO_THROW(fh.terminate()); } - + { FHandle fh("/dev/zero"); BOOST_CHECK(fh.readable()); @@ -94,6 +98,7 @@ BOOST_AUTO_UNIT_TEST(fileHandle) if (fcntl(fds[1],F_SETFL,flags|O_NONBLOCK) == -1) BOOST_FAIL(strerror(errno)); char buffer[1024]; + ::memset(buffer, 0, sizeof(buffer)); while (write(fds[1],buffer,1024) == 1024) ; FHandle fh2(fds[1]); @@ -104,12 +109,17 @@ BOOST_AUTO_UNIT_TEST(fileHandle) BOOST_FAIL(ex.what()); } } - + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ // 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: