replaced all BOOST_CHECK_NO_THROW with SENF_CHECK_NO_THROW
tho [Wed, 18 Feb 2009 17:23:25 +0000 (17:23 +0000)]
added more tests to increase test coverage

git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1126 270642c3-0616-0410-b53a-bc976706d245

35 files changed:
PPI/Connectors.test.cc
Packets/80221Bundle/MIHPacket.test.cc
Packets/80221Bundle/TLVPacket.test.cc
Packets/MPEGDVBBundle/TransportPacket.test.cc
Packets/PacketInterpreter.test.cc
Packets/PacketParser.test.cc
Scheduler/Scheduler.test.cc
Socket/ClientSocketHandle.test.cc
Socket/FileHandle.test.cc
Socket/NetdeviceController.test.cc
Socket/Protocols/INet/INet4Address.cc
Socket/Protocols/INet/INet4Address.cci
Socket/Protocols/INet/INet4Address.hh
Socket/Protocols/INet/INet4Address.test.cc
Socket/Protocols/INet/INet6Address.cc
Socket/Protocols/INet/INet6Address.cci
Socket/Protocols/INet/INet6Address.hh
Socket/Protocols/INet/INet6Address.test.cc
Socket/Protocols/INet/INetAddressing.test.cc
Socket/Protocols/INet/RawINetSocketHandle.test.cc
Socket/Protocols/INet/TCPSocketHandle.test.cc
Socket/Protocols/INet/UDPSocketHandle.test.cc
Socket/Protocols/Raw/MACAddress.test.cc
Socket/Protocols/Raw/PacketSocketHandle.test.cc
Socket/Protocols/Raw/TunTapSocketHandle.test.cc
Socket/ServerSocketHandle.test.cc
Socket/SocketHandle.test.cc
Socket/SocketPolicy.test.cc
Utils/Console/OverloadedCommand.test.cc
Utils/Console/Parse.test.cc
Utils/Console/ParsedCommand.test.cc
Utils/Console/STLSupport.test.cc
Utils/Console/Traits.test.cc
Utils/Daemon/Daemon.test.cc
Utils/Logger/FileTarget.test.cc [new file with mode: 0644]

index 2e599ba..a793d26 100644 (file)
@@ -402,22 +402,22 @@ BOOST_AUTO_UNIT_TEST(connectorTest)
     {
         TypedPassiveInput<> input;
         TypedActiveOutput<> output;
-        BOOST_CHECK_NO_THROW( ppi::connect(output, input) );
+        SENF_CHECK_NO_THROW( ppi::connect(output, input) );
     }
     { 
         TypedPassiveInput<> input;
         debug::ActiveSource output;
-        BOOST_CHECK_NO_THROW( ppi::connect(output, input) );
+        SENF_CHECK_NO_THROW( ppi::connect(output, input) );
     }
     {
         debug::ActiveSink input;
         TypedPassiveOutput<> output;
-        BOOST_CHECK_NO_THROW( ppi::connect(output, input) );
+        SENF_CHECK_NO_THROW( ppi::connect(output, input) );
     }
     {
         debug::ActiveSink input;
         debug::PassiveSource output;
-        BOOST_CHECK_NO_THROW( ppi::connect(output, input) );
+        SENF_CHECK_NO_THROW( ppi::connect(output, input) );
     }
 }
 
index 675bc61..4fcbdbc 100644 (file)
@@ -60,6 +60,9 @@ BOOST_AUTO_UNIT_TEST(MIHPacket_create_string)
     BOOST_CHECK_EQUAL( mihPacket->src_mihfId().asString(), "senf@berlios.de");
     BOOST_CHECK_EQUAL( mihPacket->dst_mihfId().asString(), "test");
 
+    // the maximum length of a MIHF_ID is 253 octets
+    BOOST_CHECK_THROW( mihPacket->dst_mihfId().setString( std::string(254, 'x')), std::length_error);
+
     // now expand a MIHF_ID
     mihPacket->dst_mihfId().maxLengthValue(253);
     mihPacket->dst_mihfId().setString( std::string(200, 'x'));
index b5c4949..2ba1864 100644 (file)
@@ -44,6 +44,8 @@ void check_TLVPacket(GenericTLVPacket &tlvPacket, boost::uint8_t type, boost::ui
     BOOST_CHECK_EQUAL( tlvPacket->type(),         type   );
     BOOST_CHECK_EQUAL( tlvPacket->length(),       length );
     BOOST_CHECK_EQUAL( tlvPacket->value().size(), int(length) );
+    std::ostringstream oss (std::ostringstream::out);
+    SENF_CHECK_NO_THROW( tlvPacket.dump( oss));
     senf::PacketData::iterator dataIterator (tlvPacket->value().begin());
     for (unsigned i=0; i<length; i++) {
         BOOST_CHECK_EQUAL( *dataIterator, i );
@@ -105,6 +107,7 @@ BOOST_AUTO_UNIT_TEST(GenericTLVPacket_create_packet_with_extended_length)
     for (unsigned i=0; i<sizeof(value); i++)
         value[i] = i;
     GenericTLVPacket tlvPacket (GenericTLVPacket::create());
+    tlvPacket->maxLengthValue( DynamicTLVLengthParser::max_value);
     tlvPacket->type() = 42u;
     tlvPacket->value( value);
     tlvPacket.finalizeThis();
index c3cc1a7..caa2b02 100644 (file)
@@ -116,6 +116,8 @@ BOOST_AUTO_UNIT_TEST(transportPacket_create_with_pusi)
             0x1d, 0xc4, 0xe8, 0xc1
     };
     senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data));
+
+    // TODO: add method for stuffing
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
index c790d21..679940a 100644 (file)
@@ -129,7 +129,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
     }
 
     {
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             senf::PacketInterpreter<OtherPacket>::create(4u,senf::noinit));
         senf::PacketInterpreter<OtherPacket>::ptr p
             (senf::PacketInterpreter<OtherPacket>::create(senf::noinit));
@@ -178,7 +178,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter)
         BOOST_CHECK_EQUAL( p2->data()[0], 0x01u );
         BOOST_CHECK_THROW( senf::PacketInterpreter<OtherPacket>::createAfter(p, size_type(4u)),
                            senf::TruncatedPacketException );
-        BOOST_CHECK_NO_THROW( senf::PacketInterpreter<OtherPacket>::createAfter(
+        SENF_CHECK_NO_THROW( senf::PacketInterpreter<OtherPacket>::createAfter(
                                   p,4u,senf::noinit) );
     }
 
index 66d84f3..7adc52a 100644 (file)
@@ -77,7 +77,7 @@ BOOST_AUTO_UNIT_TEST(packetParserBase)
     BOOST_CHECK( pi->data().begin() == p.i() );
     BOOST_CHECK( p.check(6u) );
     BOOST_CHECK( ! p.check(7u) );
-    BOOST_CHECK_NO_THROW( p.validate(6u) );
+    SENF_CHECK_NO_THROW( p.validate(6u) );
     BOOST_CHECK_THROW( p.validate(7u), senf::TruncatedPacketException );
 
     // ?? Why the heck do I need the +0? I get an 'undefined symbol FooParser::fixed_bytes'
index b8c5b50..2254cdb 100644 (file)
@@ -248,7 +248,7 @@ void schedulerTest()
         senf::scheduler::FdEvent fde1 ("testFdEvent", boost::bind(&callback, sock, _1),
                                       sock, senf::scheduler::FdEvent::EV_READ);
         event = senf::scheduler::FdEvent::EV_NONE;
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_READ );
         BOOST_REQUIRE_EQUAL( size, 4 );
         buffer[size]=0;
@@ -260,13 +260,13 @@ void schedulerTest()
         strcpy(buffer,"WRITE");
         size=5;
         event = senf::scheduler::FdEvent::EV_NONE;
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_WRITE );
 
         SENF_CHECK_NO_THROW( fde2.disable() );
         event = senf::scheduler::FdEvent::EV_NONE;
         sleep(1);
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_READ|senf::scheduler::FdEvent::EV_HUP );
         BOOST_REQUIRE_EQUAL( size, 2 );
         buffer[size]=0;
@@ -281,23 +281,23 @@ void schedulerTest()
                                             
         event = senf::scheduler::FdEvent::EV_NONE;
         senf::ClockService::clock_type t (senf::ClockService::now());
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(200)) );
         BOOST_CHECK( timeoutCalled );
         BOOST_CHECK( ! timer1.enabled() );
         BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_NONE );
         BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (senf::scheduler::eventTime()) );
         timeoutCalled = false;
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()-t) (senf::ClockService::milliseconds(400)) );
         BOOST_CHECK( timeoutCalled );
         BOOST_CHECK_EQUAL( event, senf::scheduler::FdEvent::EV_NONE );
         BOOST_CHECK( ! timer2.enabled() );
 
         BOOST_WARN_MESSAGE( false, "A 'Scheduler task hanging' error is expected to be signaled here." );
-        BOOST_CHECK_NO_THROW( timer1.action(&blockingHandler) );
-        BOOST_CHECK_NO_THROW( timer1.timeout(senf::ClockService::now()) );
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() );
+        SENF_CHECK_NO_THROW( timer1.action(&blockingHandler) );
+        SENF_CHECK_NO_THROW( timer1.timeout(senf::ClockService::now()) );
+        SENF_CHECK_NO_THROW( senf::scheduler::process() );
         BOOST_CHECK_EQUAL( senf::scheduler::hangCount(), 1u );
     }
 
@@ -309,10 +309,10 @@ void schedulerTest()
         senf::ClockService::clock_type t = senf::ClockService::now();
         ::kill(::getpid(), SIGUSR1);
         delay(200);
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() ); 
+        SENF_CHECK_NO_THROW( senf::scheduler::process() ); 
         BOOST_CHECK_PREDICATE( is_close, (senf::ClockService::now()) (t+senf::ClockService::milliseconds(200)) );
         BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
-        BOOST_CHECK_NO_THROW( senf::scheduler::process() ); 
+        SENF_CHECK_NO_THROW( senf::scheduler::process() ); 
     } 
 
     BOOST_CHECK( eventCount >= 8u );
@@ -365,14 +365,14 @@ BOOST_AUTO_UNIT_TEST(blockSignals)
     senf::scheduler::SignalEvent sig (SIGUSR1, &sigusr);
     
     senf::ClockService::clock_type t = senf::ClockService::now();
-    BOOST_CHECK_NO_THROW( senf::scheduler::process() ); 
+    SENF_CHECK_NO_THROW( senf::scheduler::process() ); 
 
     BOOST_CHECK_PREDICATE( is_close, 
                            (senf::ClockService::now()) 
                            (t+senf::ClockService::milliseconds(200)) );
     BOOST_CHECK_PREDICATE( is_close, (sigtime) (t+senf::ClockService::milliseconds(200)) );
 
-    BOOST_CHECK_NO_THROW( senf::scheduler::process() ); 
+    SENF_CHECK_NO_THROW( senf::scheduler::process() ); 
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
index 9dda3e7..0d6e994 100644 (file)
@@ -74,7 +74,7 @@ BOOST_AUTO_UNIT_TEST(clientSocketHandle)
         BOOST_CHECKPOINT("static_casting socket handle");
         SomeSocketHandle ssh =
             senf::static_socket_cast<SomeSocketHandle>(osh);
-        BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
+        SENF_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
         typedef senf::ClientSocketHandle<senf::MakeSocketPolicy<
             OtherSocketPolicy,
             senf::NoAddressingPolicy
@@ -84,52 +84,52 @@ BOOST_AUTO_UNIT_TEST(clientSocketHandle)
     }
 
     // reading and writing
-    BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.read(), "TEST-READ" ) );
+    SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.read(), "TEST-READ" ) );
     {
         std::string buf("FOO-BAR");
-        BOOST_CHECK_NO_THROW( myh.read(buf,0) );
+        SENF_CHECK_NO_THROW( myh.read(buf,0) );
         BOOST_CHECK_EQUAL( buf, "TEST-READ" );
     }
     {
         char buf[11];
         ::strcpy(buf,"0123456789");
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.read(buf,buf+10), buf+9 ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.read(buf,buf+10), buf+9 ) );
         BOOST_CHECK_EQUAL( buf, "TEST-READ9" );
     }
 
-    BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.readfrom().first, "TEST-READ" ) );
+    SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.readfrom().first, "TEST-READ" ) );
     {
         std::string buf("FOO-BAR");
         unsigned addr;
-        BOOST_CHECK_NO_THROW( myh.readfrom(buf,addr,0) );
+        SENF_CHECK_NO_THROW( myh.readfrom(buf,addr,0) );
         BOOST_CHECK_EQUAL( buf, "TEST-READ" );
     }
     {
         char buf[11];
         unsigned addr;
         ::strcpy(buf,"0123456789");
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.readfrom(buf,buf+10,addr), buf+9 ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.readfrom(buf,buf+10,addr), buf+9 ) );
         BOOST_CHECK_EQUAL( buf, "TEST-READ9" );
     }
 
     {
         std::string s ("TEST-WRITE");
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.write(s)-s.begin(), 10 ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.write(s)-s.begin(), 10 ) );
         s = "TEST";
         // This simulates a closed file in this test policy. However, we
         // have changed the semantics so this will not work anymore.
         // BOOST_CHECK_THROW( myh.write(s),senf::SystemException );
         char const * const s1 = "TEST-WRITE9";
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.write(s1,s1+10), s1+10u ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.write(s1,s1+10), s1+10u ) );
         s = "TEST-WRITE";
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.writeto(0,s)-s.begin(), 10 ) );
-        BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.writeto(0,s1,s1+10), s1+10 ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.writeto(0,s)-s.begin(), 10 ) );
+        SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.writeto(0,s1,s1+10), s1+10 ) );
     }
 
-    BOOST_CHECK_NO_THROW( myh.connect(0) );
-    BOOST_CHECK_NO_THROW( myh.bind(0) );
-    BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.peer(), 1u ) );
-    BOOST_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.local(), 2u ) );
+    SENF_CHECK_NO_THROW( myh.connect(0) );
+    SENF_CHECK_NO_THROW( myh.bind(0) );
+    SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.peer(), 1u ) );
+    SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( myh.local(), 2u ) );
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
index 6835f15..8e68d9a 100644 (file)
@@ -73,9 +73,9 @@ BOOST_AUTO_UNIT_TEST(fileHandle)
             BOOST_CHECK_EQUAL(fh.fd(), fh2.fd());
 
             BOOST_CHECK(fh.writeable());
-            BOOST_CHECK_NO_THROW(fh.close());
+            SENF_CHECK_NO_THROW(fh.close());
             BOOST_CHECK_THROW(fh.close(),senf::SystemException);
-            BOOST_CHECK_NO_THROW(fh.terminate());
+            SENF_CHECK_NO_THROW(fh.terminate());
         }
 
         {
index 649cb02..a55102e 100644 (file)
@@ -41,16 +41,16 @@ BOOST_AUTO_UNIT_TEST(NetdeviceController) {
     BOOST_CHECK_EQUAL( ctrl.interfaceName(), "lo");
 
     int oldMTU;
-    BOOST_CHECK_NO_THROW( oldMTU = ctrl.mtu());
+    SENF_CHECK_NO_THROW( oldMTU = ctrl.mtu());
 
     if (getuid() != 0) {
         BOOST_WARN_MESSAGE(false, "Cannot run some tests of senf::NetdeviceController as non-root user");
         return;
     }
 
-    BOOST_CHECK_NO_THROW( ctrl.mtu(oldMTU-16));
+    SENF_CHECK_NO_THROW( ctrl.mtu(oldMTU-16));
     BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU-16);
-    BOOST_CHECK_NO_THROW( ctrl.mtu(oldMTU));
+    SENF_CHECK_NO_THROW( ctrl.mtu(oldMTU));
     BOOST_CHECK_EQUAL( ctrl.mtu(), oldMTU);
 }
 
index 33720d3..e162200 100644 (file)
@@ -125,7 +125,7 @@ senf::INet4Address const senf::INet4Address::Broadcast (0xFFFFFFFFu);
 ///////////////////////////////////////////////////////////////////////////
 // senf::INet4Network
 
-prefix_ senf::INet4Network::INet4Network(std::string s)
+prefix_ senf::INet4Network::INet4Network(std::string const & s)
 {
     std::string::size_type i (s.find('/'));
     if (i == std::string::npos)
index b85ddaf..5cdc887 100644 (file)
@@ -104,7 +104,7 @@ prefix_ senf::INet4Network::INet4Network()
     : prefix_len_(), address_()
 {}
 
-prefix_ senf::INet4Network::INet4Network(INet4Address address, unsigned prefix_len)
+prefix_ senf::INet4Network::INet4Network(INet4Address const & address, unsigned prefix_len)
     : prefix_len_(prefix_len), address_(INet4Address(address.address() & mask()))
 {}
 
@@ -126,13 +126,13 @@ prefix_ bool senf::INet4Network::operator==(INet4Network const & other)
     return address() == other.address() && prefix_len() == other.prefix_len();
 }
 
-prefix_ bool senf::INet4Network::match(INet4Address addr)
+prefix_ bool senf::INet4Network::match(INet4Address const & addr)
     const
 {
     return (addr.address() & mask()) == address_.address();
 }
 
-prefix_ bool senf::INet4Network::match(INet4Network net)
+prefix_ bool senf::INet4Network::match(INet4Network const & net)
     const
 {
     return net.prefix_len() >= prefix_len() && match(net.address());
@@ -160,7 +160,7 @@ prefix_ std::ostream & senf::operator<<(std::ostream & os, INet4Network const &
 ///////////////////////////////cci.e///////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index 4b5f3ec..fc21d0a 100644 (file)
@@ -223,9 +223,9 @@ namespace senf {
         ///@{
 
         INet4Network();                 ///< Construct empty (0.0.0.0/0) network
-        INet4Network(INet4Address address, unsigned prefix_len);
+        INet4Network(INet4Address const & address, unsigned prefix_len);
                                         ///< Construct network from given address and prefix length
-        explicit INet4Network(std::string s); ///< Construct network from CIDR notation
+        explicit INet4Network(std::string const & s); ///< Construct network from CIDR notation
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
@@ -237,8 +237,8 @@ namespace senf {
         bool operator==(INet4Network const & other) const;
                                         ///< Compare to networks for equality
 
-        bool match(INet4Address addr) const; ///< \c true, if the network includes \a addr
-        bool match(INet4Network net) const; ///< \c true, if the network includes \a net
+        bool match(INet4Address const & addr) const; ///< \c true, if the network includes \a addr
+        bool match(INet4Network const & net) const; ///< \c true, if the network includes \a net
                                         /**< The is true, if \a net is sub-network (or the same as)
                                              \c this. */
 
index 7ff1539..b026788 100644 (file)
 
 BOOST_AUTO_UNIT_TEST(inet4Address)
 {
-    senf::INet4Address addr (senf::INet4Address::from_string("127.0.0.1"));
-    BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
-    BOOST_CHECK( addr != senf::INet4Address::Broadcast );
+    using senf::INet4Address;
+    using senf::AddressSyntaxException;
+    using senf::UnknownHostnameException;
 
-    addr = senf::INet4Address::from_string("localhost");
-    BOOST_CHECK_EQUAL( addr, senf::INet4Address::Loopback );
+    INet4Address addr (INet4Address::from_string("127.0.0.1"));
+    BOOST_CHECK_EQUAL( addr, INet4Address::Loopback );
+    BOOST_CHECK( addr != INet4Address::Broadcast );
+
+    addr = INet4Address::from_string("localhost");
+    BOOST_CHECK_EQUAL( addr, INet4Address::Loopback );
     BOOST_CHECK( addr.loopback() );
 
     char data[] = { 128, 129, 130, 131 };
-    addr = senf::INet4Address::from_data(data);
-    BOOST_CHECK_EQUAL( addr, senf::INet4Address::from_string("128.129.130.131") );
+    addr = INet4Address::from_data(data);
+    BOOST_CHECK_EQUAL( addr, INet4Address::from_string("128.129.130.131") );
     BOOST_CHECK_EQUAL( addr.inaddr(), htonl(0x80818283u) );
     BOOST_CHECK_EQUAL( addr.address(), 0x80818283u );
 
     BOOST_CHECK( ! addr.loopback() );
     BOOST_CHECK( ! addr.local() );
-    BOOST_CHECK( senf::INet4Address::from_string("192.168.1.2").local() );
+    BOOST_CHECK( INet4Address::from_string("192.168.1.2").local() );
     BOOST_CHECK( ! addr.multicast() );
-    BOOST_CHECK( senf::INet4Address::from_string("224.1.2.3").multicast() );
+    BOOST_CHECK( INet4Address::from_string("224.1.2.3").multicast() );
     BOOST_CHECK( ! addr.broadcast() );
-    BOOST_CHECK( senf::INet4Address::from_string("255.255.255.255").broadcast() );
+    BOOST_CHECK( INet4Address::from_string("255.255.255.255").broadcast() );
     BOOST_CHECK( addr );
-    BOOST_CHECK( ! senf::INet4Address() );
+    BOOST_CHECK( ! INet4Address() );
+    BOOST_CHECK_THROW( INet4Address::from_string(""), AddressSyntaxException );
+    BOOST_CHECK( INet4Address::from_string("www.6bone.net") != INet4Address::None );
+    BOOST_CHECK_THROW( INet4Address::from_string("invalid.host.fhg.de"), UnknownHostnameException);
 
     std::stringstream str;
+    str >> addr;
+    BOOST_CHECK( str.fail());
+    str.clear();
     str << addr;
     BOOST_CHECK_EQUAL( str.str(), "128.129.130.131" );
-    
     str >> addr;
-    BOOST_CHECK_EQUAL(addr, senf::INet4Address::from_string("128.129.130.131") );
+    BOOST_CHECK( ! str.fail());
+    BOOST_CHECK_EQUAL(addr, INet4Address::from_string("128.129.130.131") );
 }
 
 BOOST_AUTO_UNIT_TEST(inet4Network)
@@ -79,7 +89,7 @@ BOOST_AUTO_UNIT_TEST(inet4Network)
     BOOST_CHECK_EQUAL( net.prefix_len(), 8u );
     BOOST_CHECK( net );
     BOOST_CHECK( ! senf::INet4Network() );
-    
+
     senf::INet4Network net2 ("192.0.111.222/16");
     BOOST_CHECK_EQUAL( net2.address(), senf::INet4Address::from_string("192.0.0.0") );
     BOOST_CHECK_EQUAL( net2.prefix_len(), 16u );
@@ -95,12 +105,15 @@ BOOST_AUTO_UNIT_TEST(inet4Network)
 
     BOOST_CHECK_EQUAL( net2.host(-1), senf::INet4Address::from_string("192.0.255.255") );
     BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(net2.subnet(2u,24u)), "192.0.2.0/24" );
+
+    BOOST_CHECK_THROW( senf::INet4Network(""), senf::AddressSyntaxException );
+    BOOST_CHECK_THROW( senf::INet4Network("192.0.2.0/24/beef"), senf::AddressSyntaxException );
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index 94afd47..9d16e19 100644 (file)
@@ -124,7 +124,7 @@ senf::INet6Address const senf::INet6Address::AllRouters (0xFF02u,0u,0u,0u,0u,0u,
 ///////////////////////////////////////////////////////////////////////////
 // senf::INet6Network
 
-prefix_ senf::INet6Network::INet6Network(std::string s)
+prefix_ senf::INet6Network::INet6Network(std::string const & s)
 {
     using boost::lambda::_1;
     using boost::lambda::_2;
index 61fa0c6..93ab3c0 100644 (file)
@@ -63,7 +63,7 @@ prefix_ senf::INet6Address senf::INet6Address::from_in6addr(in6_addr const & in6
     return senf::INet6Address::from_data(&in6addr.s6_addr[0]);
 }
 
-prefix_ senf::INet6Address senf::INet6Address::from_inet4address(INet4Address addr4)
+prefix_ senf::INet6Address senf::INet6Address::from_inet4address(INet4Address const & addr4)
 {
     INet6Address addr;
     addr[10] = 0xffu;
@@ -75,7 +75,7 @@ prefix_ senf::INet6Address senf::INet6Address::from_inet4address(INet4Address ad
 prefix_ boost::uint64_t senf::INet6Address::network()
     const
 {
-    return 
+    return
         ((boost::uint64_t((*this)[0]) & 0xff) << 56 ) |
         ((boost::uint64_t((*this)[1]) & 0xff) << 48 ) |
         ((boost::uint64_t((*this)[2]) & 0xff) << 40 ) |
@@ -89,7 +89,7 @@ prefix_ boost::uint64_t senf::INet6Address::network()
 prefix_ boost::uint64_t senf::INet6Address::id()
     const
 {
-    return 
+    return
         ((boost::uint64_t((*this)[ 8]) & 0xff) << 56 ) |
         ((boost::uint64_t((*this)[ 9]) & 0xff) << 48 ) |
         ((boost::uint64_t((*this)[10]) & 0xff) << 40 ) |
@@ -138,9 +138,9 @@ prefix_ senf::INet6Address::ScopeId senf::INet6Address::scope()
             AdminScope, SiteScope, UnassignedScope, UnassignedScope,
             OrganizationScope, UnassignedScope, UnassignedScope, UnassignedScope,
             UnassignedScope, UnassignedScope, GlobalScope, ReservedScope };
-    return multicast() ? scopeMap[(*this)[1] & 0x0Fu] : 
-        (*this)[0] == 0xFEu ? (((*this)[1]&0xC0) == 0x80 ? LinkScope : 
-                               ((*this)[1]&0xC0) == 0xC0 ? SiteScope : GlobalScope ) 
+    return multicast() ? scopeMap[(*this)[1] & 0x0Fu] :
+        (*this)[0] == 0xFEu ? (((*this)[1]&0xC0) == 0x80 ? LinkScope :
+                               ((*this)[1]&0xC0) == 0xC0 ? SiteScope : GlobalScope )
         : GlobalScope;
 }
 
@@ -161,7 +161,7 @@ prefix_ bool senf::INet6Address::globalScope()
 {
     return scope() == GlobalScope;
 }
+
 prefix_ bool senf::INet6Address::linkScope()
     const
 {
@@ -230,7 +230,7 @@ prefix_ senf::INet6Network::INet6Network()
     : prefix_len_(), address_()
 {}
 
-prefix_ senf::INet6Network::INet6Network(INet6Address address, unsigned prefix_len)
+prefix_ senf::INet6Network::INet6Network(INet6Address const & address, unsigned prefix_len)
     : prefix_len_(prefix_len), address_(address)
 {
     using boost::lambda::_1;
@@ -262,7 +262,7 @@ prefix_ bool senf::INet6Network::operator==(INet6Network const & other)
     return prefix_len() == other.prefix_len() && address() == other.address();
 }
 
-prefix_ bool senf::INet6Network::match(INet6Address addr)
+prefix_ bool senf::INet6Network::match(INet6Address const & addr)
     const
 {
     using boost::lambda::_1;
@@ -272,7 +272,7 @@ prefix_ bool senf::INet6Network::match(INet6Address addr)
                                 _1 != (_2 & _3)) == address_.end();
 }
 
-prefix_ bool senf::INet6Network::match(INet6Network net)
+prefix_ bool senf::INet6Network::match(INet6Network const & net)
     const
 {
     return net.prefix_len() >= prefix_len() && match(net.address());
@@ -316,7 +316,7 @@ prefix_ boost::uint8_t senf::detail::low_bits_mask(unsigned bits)
 ///////////////////////////////cci.e///////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index a959837..953bc49 100644 (file)
@@ -193,7 +193,7 @@ namespace senf {
                                              data as accessed by the iterator. The data must be in
                                              network byte order. */
 
-        static INet6Address from_inet4address(INet4Address addr);
+        static INet6Address from_inet4address(INet4Address const & addr);
                                         ///< Construct an INet6-mapped INet4 address
                                         /**< This will construct an address of the form
                                              <tt>::FFFF::w.x.y.z</tt> where <tt>w.x.y.z</tt> is
@@ -335,9 +335,9 @@ namespace senf {
         ///@{
 
         INet6Network();                 ///< Construct empty (::/0) network
-        INet6Network(INet6Address address, unsigned prefix_len);
+        INet6Network(INet6Address const & address, unsigned prefix_len);
                                         ///< Construct network from given address and prefix length
-        explicit INet6Network(std::string s); ///< Construct network from CIDR notation
+        explicit INet6Network(std::string const & s); ///< Construct network from CIDR notation
 
         ///@}
         ///////////////////////////////////////////////////////////////////////////
@@ -349,8 +349,8 @@ namespace senf {
         bool operator==(INet6Network const & other) const;
                                         ///< Compare two networks for equality
 
-        bool match(INet6Address addr) const; ///< \c true, if the network includes \a addr
-        bool match(INet6Network net) const; ///< \c true, if the network includes \a net
+        bool match(INet6Address const & addr) const; ///< \c true, if the network includes \a addr
+        bool match(INet6Network const & net) const; ///< \c true, if the network includes \a net
                                         /**< The is true, if \a net is sub-network (or the same as)
                                              \c this. */
         INet6Address host(boost::uint64_t id); ///< Return the host with the given id
index 4932467..3bdce5a 100644 (file)
@@ -122,19 +122,25 @@ BOOST_AUTO_UNIT_TEST(inet6Address)
         BOOST_CHECK( INet6Address(0u,0u,0u,0u,0u,0xFFFF,0x0102,0x0304).inet4Mapped() );
         BOOST_CHECK( ! addr.inet4Compatible() );
         BOOST_CHECK( ! addr.inet4Mapped() );
-    
+
         BOOST_CHECK( INet6Address::AllNodes.globalMulticastAddr() );
         BOOST_CHECK( ! INet6Address::AllNodes.prefixMulticastAddr() );
         BOOST_CHECK( ! INet6Address::AllNodes.embeddedRpAddr() );
 
         BOOST_CHECK( INet6Address::Loopback );
         BOOST_CHECK( ! INet6Address::None );
-        
+    }
+
+    {
+        INet6Address addr (INet6Address::from_string("2001:dead:beef::1002:3004"));
         std::stringstream str;
+        str >> addr;
+        BOOST_CHECK( str.fail());
+        str.clear();
         str << addr;
         BOOST_CHECK_EQUAL( str.str(), "2001:dead:beef::1002:3004");
-        
         str >> addr;
+        BOOST_CHECK( ! str.fail());
         BOOST_CHECK_EQUAL(addr, INet6Address::from_string("2001:dead:beef::1002:3004"));
     }
 
@@ -149,34 +155,41 @@ BOOST_AUTO_UNIT_TEST(inet6Address)
 
 BOOST_AUTO_UNIT_TEST(inet6Network)
 {
-    senf::INet6Network net (senf::INet6Address(0xFF14u,0x1234u),32u);
+    using senf::INet6Address;
+    using senf::INet6Network;
+    using senf::AddressSyntaxException;
+
+    INet6Network net (INet6Address(0xFF14u,0x1234u),32u);
     BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(net.address()), "ff14:1234::");
     BOOST_CHECK_EQUAL( net.prefix_len(), 32u );
     BOOST_CHECK( net );
-    BOOST_CHECK( ! senf::INet6Network() );
-    
-    senf::INet6Network net2 ("2001:db8:1234::/44");
-    BOOST_CHECK_EQUAL( net2.address(), senf::INet6Address::from_string("2001:db8:1230::") );
+    BOOST_CHECK( ! INet6Network() );
+
+    INet6Network net2 ("2001:db8:1234::/44");
+    BOOST_CHECK_EQUAL( net2.address(), INet6Address::from_string("2001:db8:1230::") );
     BOOST_CHECK_EQUAL( net2.prefix_len(), 44u );
 
     BOOST_CHECK( net != net2 );
-    BOOST_CHECK( net.match(senf::INet6Address::from_string("ff14:1234::1")) );
-    BOOST_CHECK( ! net2.match(senf::INet6Address::from_string("ff13:1234::1")) );
+    BOOST_CHECK( net.match(INet6Address::from_string("ff14:1234::1")) );
+    BOOST_CHECK( ! net2.match(INet6Address::from_string("ff13:1234::1")) );
     BOOST_CHECK( ! net.match(net2) );
-    BOOST_CHECK( net2.match(senf::INet6Network("2001:db8:1234::/48")) );
-    BOOST_CHECK( ! net2.match(senf::INet6Network("2001:db8:1234::/32")) );
+    BOOST_CHECK( net2.match(INet6Network("2001:db8:1234::/48")) );
+    BOOST_CHECK( ! net2.match(INet6Network("2001:db8:1234::/32")) );
 
     BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(net2), "2001:db8:1230::/44" );
 
-    BOOST_CHECK_EQUAL( net2.host(0x1234u), senf::INet6Address::from_string("2001:db8:1230::1234") );
-    BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(net2.subnet(2u,48u)), 
+    BOOST_CHECK_EQUAL( net2.host(0x1234u), INet6Address::from_string("2001:db8:1230::1234") );
+    BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(net2.subnet(2u,48u)),
                        "2001:db8:1232::/48" );
+
+    BOOST_CHECK_THROW( INet6Network(""), AddressSyntaxException );
+    BOOST_CHECK_THROW( INet6Network("2001:db8:1234::/beef"), AddressSyntaxException );
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index 0c7a7b0..8049dac 100644 (file)
@@ -42,7 +42,7 @@ BOOST_AUTO_UNIT_TEST(inet4SocketAddress)
 
     {
         INet4SocketAddress addr;
-        
+
         BOOST_CHECK( ! addr );
 
         addr = INet4SocketAddress("127.0.0.1:12345");
@@ -54,7 +54,7 @@ BOOST_AUTO_UNIT_TEST(inet4SocketAddress)
         INet4SocketAddress addr3(INet4Address::Loopback,12345);
     }
 
-    BOOST_CHECK_EQUAL( INet4SocketAddress("127.0.0.1:12345"), 
+    BOOST_CHECK_EQUAL( INet4SocketAddress("127.0.0.1:12345"),
                        INet4SocketAddress(INet4Address::Loopback,12345) );
 
     BOOST_CHECK_THROW( INet4SocketAddress("127.0.0.1"), AddressSyntaxException );
@@ -74,9 +74,17 @@ BOOST_AUTO_UNIT_TEST(inet4SocketAddress)
         BOOST_CHECK_EQUAL( reinterpret_cast< ::sockaddr_in * >(addr.sockaddr_p())->sin_addr.s_addr,
                            htonl(INADDR_LOOPBACK) );
 
-        std::stringstream s;
-        s << addr;
-        BOOST_CHECK_EQUAL( s.str(), "127.0.0.1:12345" );
+        BOOST_CHECK_EQUAL( addr, INet4SocketAddress(addr) );
+
+        std::stringstream str;
+        str >> addr;
+        BOOST_CHECK( str.fail());
+        str.clear();
+        str << addr;
+        BOOST_CHECK_EQUAL( str.str(), "127.0.0.1:12345" );
+        str >> addr;
+        BOOST_CHECK( ! str.fail());
+        BOOST_CHECK_EQUAL(addr, INet4SocketAddress("127.0.0.1:12345"));
     }
 }
 
@@ -92,29 +100,40 @@ BOOST_AUTO_UNIT_TEST(inet6SocketAddress)
         BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(addr.address()), "::" );
         BOOST_CHECK_EQUAL( addr.port(), 0u );
         BOOST_CHECK_EQUAL( addr.iface(), "" );
-        addr = senf::INet6SocketAddress("[12::21]:12345");
-        BOOST_CHECK( addr == senf::INet6SocketAddress("[12::21]:12345") );
-        BOOST_CHECK( addr != senf::INet6SocketAddress("[12::21%lo]:12345") );
+        addr = INet6SocketAddress("[12::21]:12345");
+        BOOST_CHECK( addr == INet6SocketAddress("[12::21]:12345") );
+        BOOST_CHECK_EQUAL( addr, INet6SocketAddress(addr) );
+        BOOST_CHECK( addr != INet6SocketAddress("[12::21%lo]:12345") );
         BOOST_CHECK( addr );
         BOOST_CHECK_EQUAL( addr.address(), INet6Address::from_string("12::21") );
         BOOST_CHECK_EQUAL( addr.port(), 12345u );
         BOOST_CHECK_EQUAL( addr.iface(), "" );
         BOOST_CHECK_EQUAL( addr, INet6SocketAddress("[12::21]:12345") );
-        BOOST_CHECK_NO_THROW( INet6SocketAddress("www.6bone.net:80") );
-        addr = senf::INet6SocketAddress("1.2.3.4:12345", INet6Address::ResolveINet4);
+        SENF_CHECK_NO_THROW( INet6SocketAddress("www.6bone.net:80") );
+        addr = INet6SocketAddress("1.2.3.4:12345", INet6Address::ResolveINet4);
         BOOST_CHECK_EQUAL( addr.address(), INet6Address::from_string("::ffff:1.2.3.4") );
         BOOST_CHECK_EQUAL( addr.port(), 12345u );
+
+        std::stringstream str;
+        str >> addr;
+        BOOST_CHECK( str.fail());
+        str.clear();
+        str << addr;
+        BOOST_CHECK_EQUAL( str.str(), "[::ffff:1.2.3.4]:12345");
+        str >> addr;
+        BOOST_CHECK( ! str.fail());
+        BOOST_CHECK_EQUAL(addr, INet6SocketAddress("[::ffff:1.2.3.4]:12345"));
     }
 
     {
         INet6SocketAddress addr (INet6Address::from_string("::1"), 1);
-        BOOST_CHECK_EQUAL( addr,senf::INet6SocketAddress("[::1]:1") );
+        BOOST_CHECK_EQUAL( addr, INet6SocketAddress("[::1]:1") );
         BOOST_CHECK_EQUAL( addr.iface(), "" );
     }
 
     {
         INet6SocketAddress addr (INet6Address::Loopback, 1, "lo");
-        BOOST_CHECK_EQUAL( addr, senf::INet6SocketAddress("[::1%lo]:1") );
+        BOOST_CHECK_EQUAL( addr, INet6SocketAddress("[::1%lo]:1") );
         BOOST_CHECK_EQUAL( addr.iface(), "lo" );
         addr.iface("");
         BOOST_CHECK_EQUAL( addr.iface(), "" );
@@ -122,12 +141,10 @@ BOOST_AUTO_UNIT_TEST(inet6SocketAddress)
         BOOST_CHECK_EQUAL( addr.port(), 100u );
         addr.address(INet6Address::from_string("::2"));
         BOOST_CHECK_EQUAL( addr.address(), INet6Address::from_string("::2") );
-        BOOST_CHECK_THROW( senf::INet6SocketAddress(""), AddressSyntaxException );
-        BOOST_CHECK_THROW( senf::INet6SocketAddress("[::1]"), 
-                           AddressSyntaxException );
-        BOOST_CHECK_THROW( senf::INet6SocketAddress("[::1]1234"), 
-                           AddressSyntaxException );
-        addr = senf::INet6SocketAddress("[12::21%lo]:12345");
+        BOOST_CHECK_THROW( INet6SocketAddress(""), AddressSyntaxException );
+        BOOST_CHECK_THROW( INet6SocketAddress("[::1]"), AddressSyntaxException );
+        BOOST_CHECK_THROW( INet6SocketAddress("[::1]1234"), AddressSyntaxException );
+        addr = INet6SocketAddress("[12::21%lo]:12345");
         BOOST_CHECK_EQUAL( boost::lexical_cast<std::string>(addr), "[12::21%lo]:12345" );
         BOOST_CHECK_EQUAL( addr.address(), INet6Address::from_string("12::21") );
         BOOST_CHECK_EQUAL( addr.port(), 12345u );
@@ -139,7 +156,7 @@ BOOST_AUTO_UNIT_TEST(inet6SocketAddress)
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index 696ec6d..d8949e3 100644 (file)
@@ -148,15 +148,15 @@ BOOST_AUTO_UNIT_TEST(RawV4ClientSocketHandle)
         alarm(10);
         start(server_v4);
         senf::RawV4ClientSocketHandle sock(47);  //IPPROTO_GRE
-        BOOST_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:0"), test) );
+        SENF_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:0"), test) );
         senf::RawV4ClientSocketHandle sockrec(48);  //IPPROTO_GRE+1
         std::string in = sockrec.read();
         BOOST_CHECK_EQUAL(in.substr(20), test); 
-        BOOST_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:0"),"QUIT"));
+        SENF_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:0"),"QUIT"));
         //sock.close();
         //sockrec.close();
         alarm(0);
@@ -178,15 +178,15 @@ BOOST_AUTO_UNIT_TEST(RawV6ClientSocketHandle)
         start(server_v6);
         sleep(1);
         senf::RawV6ClientSocketHandle sock(47);  //IPPROTO_GRE
-        BOOST_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.writeto(senf::INet6SocketAddress("[::1]:0"), test) );
+        SENF_CHECK_NO_THROW( sock.writeto(senf::INet6SocketAddress("[::1]:0"), test) );
         senf::RawV6ClientSocketHandle sockrec(48);  //IPPROTO_GRE+1
         std::string in = sockrec.read();
         BOOST_CHECK_EQUAL(in, test); 
-        BOOST_CHECK_NO_THROW( sock.writeto(senf::INet6SocketAddress("[::1]:0"),"QUIT"));
+        SENF_CHECK_NO_THROW( sock.writeto(senf::INet6SocketAddress("[::1]:0"),"QUIT"));
         alarm(0);
     } catch (...) {
         alarm(0);
index 70d599e..b4e8e61 100644 (file)
@@ -167,16 +167,16 @@ BOOST_AUTO_UNIT_TEST(tcpv4ClientSocketHandle)
         alarm(10);
         start(server_v4);
         senf::TCPv4ClientSocketHandle sock;
-        BOOST_CHECK_NO_THROW( sock.bind(senf::INet4SocketAddress("127.0.0.1:23456")) );
-        BOOST_CHECK_NO_THROW( sock.connect(senf::INet4SocketAddress("127.0.0.1:12345")) );
+        SENF_CHECK_NO_THROW( sock.bind(senf::INet4SocketAddress("127.0.0.1:23456")) );
+        SENF_CHECK_NO_THROW( sock.connect(senf::INet4SocketAddress("127.0.0.1:12345")) );
         BOOST_CHECK( sock.peer() == senf::INet4SocketAddress("127.0.0.1:12345") );
         BOOST_CHECK( sock.local() == senf::INet4SocketAddress("127.0.0.1:23456") );
         BOOST_CHECK( sock.blocking() );
-        BOOST_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+        SENF_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
         BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
         BOOST_CHECK( !sock.eof() );
         sock.write(std::string("QUIT"));
@@ -202,25 +202,25 @@ BOOST_AUTO_UNIT_TEST(tcpv4ClientSocketHandle)
         // are at least not sensible ...
         // I'll have to move those to a UDPSocket test ... they should
         // realy only be in the UDP Protocol implementation
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcTTL() );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcTTL() );
 //        BOOST_CHECK_THROW( sock.protocol().mcTTL(1), senf::SystemException );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcLoop() );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcLoop(false) );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0") );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0","127.0.0.1:0") );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0","127.0.0.1:0") );
-//        BOOST_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0") );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcLoop() );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcLoop(false) );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0") );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcAddMembership("224.0.0.1:0","127.0.0.1:0") );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0","127.0.0.1:0") );
+//        SENF_CHECK_NO_THROW( sock.protocol().mcDropMembership("224.0.0.1:0") );
 //        BOOST_CHECK_THROW( sock.protocol().mcIface("lo"), senf::SystemException );
 
         // The following setsockopts are hard to REALLY test ...
-        BOOST_CHECK_NO_THROW( sock.protocol().nodelay(true) );
+        SENF_CHECK_NO_THROW( sock.protocol().nodelay(true) );
         BOOST_CHECK( sock.protocol().nodelay() );
         BOOST_CHECK_EQUAL( sock.protocol().siocinq(), 0u );
         BOOST_CHECK_EQUAL( sock.protocol().siocoutq(), 0u );
 
-        BOOST_CHECK_NO_THROW( sock.protocol().reuseaddr(true) );
+        SENF_CHECK_NO_THROW( sock.protocol().reuseaddr(true) );
         BOOST_CHECK( sock.protocol().reuseaddr() );
-        BOOST_CHECK_NO_THROW( sock.protocol().linger(true,0) );
+        SENF_CHECK_NO_THROW( sock.protocol().linger(true,0) );
         BOOST_CHECK( sock.protocol().linger() == std::make_pair(true, 0u) );
     }
 }
@@ -238,19 +238,19 @@ BOOST_AUTO_UNIT_TEST(tcpv6ClientSocketHandle)
         alarm(10);
         start(server_v6);
         senf::TCPv6ClientSocketHandle sock;
-        BOOST_CHECK_NO_THROW( sock.bind(senf::INet6SocketAddress("[::1]:23456")) );
-        BOOST_CHECK_NO_THROW( sock.connect(senf::INet6SocketAddress("[::1]:12345")) );
+        SENF_CHECK_NO_THROW( sock.bind(senf::INet6SocketAddress("[::1]:23456")) );
+        SENF_CHECK_NO_THROW( sock.connect(senf::INet6SocketAddress("[::1]:12345")) );
         BOOST_CHECK( sock.peer() == senf::INet6SocketAddress("[::1]:12345") );
         BOOST_CHECK( sock.local() == senf::INet6SocketAddress("[::1]:23456") );
         BOOST_CHECK( sock.blocking() );
-        BOOST_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+        SENF_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
         BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
         // this fails with ENOFILE ... why ????
-        // BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
+        // SENF_CHECK_NO_THROW( sock.protocol().timestamp() );
         BOOST_CHECK( !sock.eof() );
         sock.write(std::string("QUIT"));
         sleep(1);
@@ -272,14 +272,14 @@ BOOST_AUTO_UNIT_TEST(tcpv6ClientSocketHandle)
         senf::TCPv6ClientSocketHandle sock;
 
         // The following setsockopts are hard to REALLY test ...
-        BOOST_CHECK_NO_THROW( sock.protocol().nodelay(true) );
+        SENF_CHECK_NO_THROW( sock.protocol().nodelay(true) );
         BOOST_CHECK( sock.protocol().nodelay() );
         BOOST_CHECK_EQUAL( sock.protocol().siocinq(), 0u );
         BOOST_CHECK_EQUAL( sock.protocol().siocoutq(), 0u );
 
-        BOOST_CHECK_NO_THROW( sock.protocol().reuseaddr(true) );
+        SENF_CHECK_NO_THROW( sock.protocol().reuseaddr(true) );
         BOOST_CHECK( sock.protocol().reuseaddr() );
-        BOOST_CHECK_NO_THROW( sock.protocol().linger(true,0) );
+        SENF_CHECK_NO_THROW( sock.protocol().linger(true,0) );
         BOOST_CHECK( sock.protocol().linger() == std::make_pair(true, 0u) );
     }
 }
@@ -349,7 +349,7 @@ BOOST_AUTO_UNIT_TEST(tcpv4ServerSocketHandle)
 
         BOOST_CHECKPOINT("Accepting connection");
         senf::TCPv4ClientSocketHandle client = server.accept();
-        BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
+        SENF_CHECK_NO_THROW(client.write(std::string("QUIT")));
 
         BOOST_CHECKPOINT("Stopping client");
         sleep(1);
@@ -375,7 +375,7 @@ BOOST_AUTO_UNIT_TEST(tcpv6ServerSocketHandle)
 
         BOOST_CHECKPOINT("Accepting connection");
         senf::TCPv6ClientSocketHandle client = server.accept();
-        BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
+        SENF_CHECK_NO_THROW(client.write(std::string("QUIT")));
 
         BOOST_CHECKPOINT("Stopping client");
         sleep(1);
index 44c51ec..ac4c7df 100644 (file)
@@ -146,16 +146,16 @@ BOOST_AUTO_UNIT_TEST(udpv4ClientSocketHandle)
         alarm(10);
         start(server_v4);
         senf::UDPv4ClientSocketHandle sock;
-        BOOST_CHECK_NO_THROW( sock.bind(senf::INet4SocketAddress("127.0.0.1:23456")) );
+        SENF_CHECK_NO_THROW( sock.bind(senf::INet4SocketAddress("127.0.0.1:23456")) );
         BOOST_CHECK( sock.local() == senf::INet4SocketAddress("127.0.0.1:23456") );
-        BOOST_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().rcvbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
+        SENF_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
         BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
-        BOOST_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"),
+        SENF_CHECK_NO_THROW( sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"),
                                            std::string("TEST-WRITE")) );
         BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
-        BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
+        SENF_CHECK_NO_THROW( sock.protocol().timestamp() );
         sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"), std::string("QUIT"));
         sleep(1);
         stop();
index 0550c1a..b2c33b7 100644 (file)
@@ -41,7 +41,7 @@ BOOST_AUTO_UNIT_TEST(macAddress)
 {
     using senf::MACAddress;
     using senf::AddressSyntaxException;
-    
+
     std::string test ("A1-b2-C3:d4:E5:f6");
     MACAddress mac (MACAddress::from_string(test));
 
@@ -53,12 +53,15 @@ BOOST_AUTO_UNIT_TEST(macAddress)
     BOOST_CHECK_EQUAL( mac[5], 0xF6u );
 
     std::stringstream str;
+    str >> mac;
+    BOOST_CHECK( str.fail());
+    str.clear();
     str << mac;
     BOOST_CHECK_EQUAL( str.str(), "a1:b2:c3:d4:e5:f6" );
-    
     str >> mac;
+    BOOST_CHECK( ! str.fail());
     BOOST_CHECK_EQUAL(mac, MACAddress::from_string(test));
-    
+
     BOOST_CHECK( ! mac.local() );
     BOOST_CHECK( mac.multicast() );
     BOOST_CHECK( ! mac.broadcast() );
@@ -86,14 +89,14 @@ BOOST_AUTO_UNIT_TEST(macAddress)
 
     BOOST_CHECK_EQUAL( mac, MACAddress::from_eui64(0xa1b2c3fffed4e5f6llu) );
     BOOST_CHECK_THROW( MACAddress::from_eui64(0u), AddressSyntaxException );
-    
+
     BOOST_CHECK_EQUAL( MACAddress(0x1a2b3c4d5e6fULL).uint64(), 0x1a2b3c4d5e6fULL);
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
 #undef prefix_
 
-\f
+
 // Local Variables:
 // mode: c++
 // fill-column: 100
index 99941e6..e3ab322 100644 (file)
@@ -48,19 +48,19 @@ BOOST_AUTO_UNIT_TEST(packetSocketHandle)
     {
         senf::PacketSocketHandle sock;
 
-        BOOST_CHECK_NO_THROW( sock.bind(senf::LLSocketAddress("eth0")) );
+        SENF_CHECK_NO_THROW( sock.bind(senf::LLSocketAddress("eth0")) );
         senf::LLSocketAddress a;
-        BOOST_CHECK_NO_THROW( sock.local(a) );
+        SENF_CHECK_NO_THROW( sock.local(a) );
         BOOST_CHECK_EQUAL( a.interface(), "eth0" );
 
         // How am I supposed to test read and write .. grmpf ..
 
-        BOOST_CHECK_NO_THROW( sock.protocol().mcAdd(
+        SENF_CHECK_NO_THROW( sock.protocol().mcAdd(
                                   "eth0",senf::MACAddress::from_string("01-02-03-04-05-06")) );
-        BOOST_CHECK_NO_THROW( sock.protocol().mcDrop(
+        SENF_CHECK_NO_THROW( sock.protocol().mcDrop(
                                   "eth0",senf::MACAddress::from_string("01-02-03-04-05-06")) );
 
-        BOOST_CHECK_NO_THROW( sock.protocol().available() );
+        SENF_CHECK_NO_THROW( sock.protocol().available() );
         BOOST_CHECK( ! sock.eof() );
     }
 }
index 45d7154..4613922 100644 (file)
@@ -51,7 +51,7 @@ BOOST_AUTO_UNIT_TEST(tapSocketHandle)
     BOOST_CHECK_EQUAL( WEXITSTATUS(ret), 0);
 
     senf::PacketSocketHandle sock;
-    BOOST_CHECK_NO_THROW( sock.bind(senf::LLSocketAddress("tap_unittest")) );
+    SENF_CHECK_NO_THROW( sock.bind(senf::LLSocketAddress("tap_unittest")) );
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
index 18f9967..3eb0a62 100644 (file)
@@ -74,13 +74,13 @@ BOOST_AUTO_UNIT_TEST(serverSocketHandle)
         >::policy> SomeOtherSocketHandle;
     typedef senf::ClientSocketHandle<OtherSocketPolicy> OtherClientHandle;
 
-    BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
+    SENF_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
     BOOST_CHECK_THROW( senf::dynamic_socket_cast<SomeOtherSocketHandle>(osh),
                        std::bad_cast );
     BOOST_CHECK_THROW( senf::dynamic_socket_cast<OtherClientHandle>(osh),
                        std::bad_cast );
 
-    BOOST_CHECK_NO_THROW( myh.bind(0) );
+    SENF_CHECK_NO_THROW( myh.bind(0) );
     BOOST_CHECK_EQUAL( myh.local(), 2u );
 
     {
index c8071f3..bb3835d 100644 (file)
@@ -80,8 +80,8 @@ BOOST_AUTO_UNIT_TEST(socketHandle)
         typedef senf::SocketHandle<senf::test::SomeSocketProtocol::Policy> SomeSocketHandle;
         SomeSocketHandle ssh = senf::static_socket_cast<SomeSocketHandle>(osh);
 
-        BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
-        BOOST_CHECK_NO_THROW( senf::dynamic_socket_cast<AnotherSocketHandle>(osh) );
+        SENF_CHECK_NO_THROW( senf::dynamic_socket_cast<SomeSocketHandle>(osh) );
+        SENF_CHECK_NO_THROW( senf::dynamic_socket_cast<AnotherSocketHandle>(osh) );
 
         typedef senf::SocketHandle< senf::MakeSocketPolicy<
             OtherSocketPolicy,
@@ -102,7 +102,7 @@ BOOST_AUTO_UNIT_TEST(socketHandle)
                            "socket.protocol.policy: senf::SocketPolicy<senf::test::SomeAddressingPolicy, senf::test::SomeFramingPolicy, senf::test::SomeCommunicationPolicy, senf::test::SomeReadPolicy, senf::test::SomeWritePolicy>\n"
                            "socket.server: false\n" );
 
-        BOOST_CHECK_NO_THROW( myh.facet<senf::test::SomeSocketProtocol>() );
+        SENF_CHECK_NO_THROW( myh.facet<senf::test::SomeSocketProtocol>() );
     }
     
     // Ensure, the destructor is called and calls the correct close() implementation
index 7063ccc..72ba433 100644 (file)
@@ -132,7 +132,7 @@ BOOST_AUTO_UNIT_TEST(socketPolicy)
         Policy3 p3;
 
         BOOST_CHECK_THROW( Policy1::checkBaseOf(p3), std::bad_cast );
-        BOOST_CHECK_NO_THROW( Policy3::checkBaseOf(p1) );
+        SENF_CHECK_NO_THROW( Policy3::checkBaseOf(p1) );
     }
 }
 
index 67d22de..5372055 100644 (file)
@@ -71,7 +71,7 @@ BOOST_AUTO_UNIT_TEST(overladedCommand)
                            senf::console::SyntaxErrorException );
         
         cmd.add(senf::console::SimpleCommandOverload::create(&fn3)).doc("fn3");
-        BOOST_CHECK_NO_THROW( senf::console::root()("overload")(ss, info) );
+        SENF_CHECK_NO_THROW( senf::console::root()("overload")(ss, info) );
         BOOST_CHECK_EQUAL( ss.str(), "fn3\n" );
     }
     
index 7b9e7be..7f85ac7 100644 (file)
@@ -200,7 +200,7 @@ BOOST_AUTO_UNIT_TEST(commandParser)
         "                   0304\";"
         "ls /foo/bar; ";
 
-    BOOST_CHECK_NO_THROW( parser.parse(text, &setInfo) );
+    SENF_CHECK_NO_THROW( parser.parse(text, &setInfo) );
     BOOST_CHECK_EQUAL( commands.size(), 2u );
 
     {
@@ -274,14 +274,14 @@ BOOST_AUTO_UNIT_TEST(checkedArgumentIterator)
 {
     senf::console::CommandParser parser;
 
-    BOOST_CHECK_NO_THROW( parser.parse("foo a", &setInfo) );
+    SENF_CHECK_NO_THROW( parser.parse("foo a", &setInfo) );
     BOOST_CHECK_THROW( parseArgs(commands.back().arguments()), 
                        senf::console::SyntaxErrorException );
 
-    BOOST_CHECK_NO_THROW( parser.parse("foo a b", &setInfo) );
-    BOOST_CHECK_NO_THROW( parseArgs(commands.back().arguments()) );
+    SENF_CHECK_NO_THROW( parser.parse("foo a b", &setInfo) );
+    SENF_CHECK_NO_THROW( parseArgs(commands.back().arguments()) );
 
-    BOOST_CHECK_NO_THROW( parser.parse("foo a b c", &setInfo) );
+    SENF_CHECK_NO_THROW( parser.parse("foo a b c", &setInfo) );
     BOOST_CHECK_THROW( parseArgs(commands.back().arguments()), 
                        senf::console::SyntaxErrorException );
     
index 42a5097..efce1ef 100644 (file)
@@ -132,7 +132,7 @@ BOOST_AUTO_UNIT_TEST(parsedCommand)
         // Just for the fun of it, use a functor and not a function pointer as parser ...
         dir.add("cb6", &cb5)
             .arg( kw::parser = TestParser() );
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb6 false",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
         BOOST_CHECK_EQUAL( ss.str(), "Value: true\n" );
@@ -145,7 +145,7 @@ BOOST_AUTO_UNIT_TEST(parsedCommand)
         // compatible types also work
         dir.add("cb7", boost::function<float()>(&cb2))
             .formatter( &testFormatter );
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb7",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
         BOOST_CHECK_EQUAL( ss.str(), "formatter\n" );
@@ -187,16 +187,16 @@ BOOST_AUTO_UNIT_TEST(parsedCommand)
 
         (void) cbNode;
 
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb 111 222.4",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb 222",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb foo",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
-        BOOST_CHECK_NO_THROW(
+        SENF_CHECK_NO_THROW(
             parser.parse("test/cb",
                          boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
 
index 8b3dcf0..a4e0cf3 100644 (file)
@@ -72,13 +72,13 @@ BOOST_AUTO_UNIT_TEST(vectorSupport)
         .arg("data", "test data", senf::console::kw::default_value = defv);
     std::stringstream ss;
 
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test; test/test (); test/test 5; test/test (13); test/test (4 5 8)",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW( 
+    SENF_CHECK_NO_THROW( 
         parser.parse("help test/test",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL(
@@ -103,13 +103,13 @@ BOOST_AUTO_UNIT_TEST(listSupport)
         .arg("data", "test data", senf::console::kw::default_value = defv);
     std::stringstream ss;
 
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test; test/test (); test/test 5; test/test (13); test/test (4 5 8)",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "9\n" "0\n" "5\n" "13\n" "17\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW( 
+    SENF_CHECK_NO_THROW( 
         parser.parse("help test/test",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL(
index b8d366b..054f993 100644 (file)
@@ -64,32 +64,32 @@ BOOST_AUTO_UNIT_TEST(boolTraits)
     dir.add("test", &boolTest);
 
     std::stringstream ss;
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test true; test/test false",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "true\n" "false\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test enabled; test/test disabled",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "true\n" "false\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test yes; test/test no",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "true\n" "false\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test Y; test/test enA",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "true\n" "true\n" );
 
     dir.add("test2", &boolTest).formatter( senf::console::formatEnabledDisabled );
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test2 0; test/test2 -1",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "disabled\n" "enabled\n" );
@@ -105,13 +105,13 @@ BOOST_AUTO_UNIT_TEST(enumSupport)
     dir.add("test",&test);
     
     std::stringstream ss;
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test Foo",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "Foo\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/test Bar",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "Bar\n" );
@@ -129,13 +129,13 @@ BOOST_AUTO_UNIT_TEST(enumSupport)
     dir.add("member", &TestClass::test);
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/member MemberFoo",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "MemberFoo\n" );
 
     ss.str("");
-    BOOST_CHECK_NO_THROW(
+    SENF_CHECK_NO_THROW(
         parser.parse("test/member MemberBar",
                      boost::bind<void>( boost::ref(executor), boost::ref(ss), _1 )) );
     BOOST_CHECK_EQUAL( ss.str(), "MemberBar\n" );
index c814ffd..8031988 100644 (file)
@@ -151,8 +151,8 @@ BOOST_AUTO_UNIT_TEST(testDaemon)
     std::stringstream data;
     data << log.rdbuf();
     BOOST_CHECK_EQUAL( data.str(), "Running init()\n(stderr)\nRunning run()\n" );
-    BOOST_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log") );
-    BOOST_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log.1") );
+    SENF_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log") );
+    SENF_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log.1") );
 }
 
 ///////////////////////////////cc.e////////////////////////////////////////
diff --git a/Utils/Logger/FileTarget.test.cc b/Utils/Logger/FileTarget.test.cc
new file mode 100644 (file)
index 0000000..8594699
--- /dev/null
@@ -0,0 +1,88 @@
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+//     Thorsten Horstmann <tho@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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+/** \file
+    \brief FileTarget unit tests */
+
+//#include "FileTarget.test.hh"
+//#include "FileTarget.test.ih"
+
+// Custom includes
+#include <fstream>
+#include <boost/filesystem/operations.hpp>
+#include "FileTarget.hh"
+#include "Logger.hh"
+
+#include "../Utils/auto_unit_test.hh"
+#include <boost/test/test_tools.hpp>
+
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+BOOST_AUTO_UNIT_TEST(fileTarget)
+{
+    std::string filename ("/tmp/senf_fileTarget_test.log");
+    senf::log::FileTarget target (filename);
+
+    target.tag("");
+    target.showTime(false);
+    target.showLevel(false);
+    target.route();
+
+    std::string message ("Test message");
+    SENF_LOG((message));
+
+    BOOST_REQUIRE( boost::filesystem::exists(filename));
+    std::ifstream inFile;
+    inFile.open(filename.c_str());
+    BOOST_REQUIRE( inFile);
+
+    char buffer[256];
+    inFile.getline(buffer, 256);
+    inFile.close();
+    BOOST_CHECK_EQUAL( std::string(buffer), message);
+
+    SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
+    
+    target.reopen();
+    BOOST_REQUIRE( boost::filesystem::exists(filename));
+    SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
+    
+    filename = std::string("/tmp/senf_fileTarget_test2.log");
+    target.reopen( filename);
+    BOOST_REQUIRE( boost::filesystem::exists(filename));
+    SENF_CHECK_NO_THROW( boost::filesystem::remove(filename) );
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End: