{
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) );
}
}
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'));
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 );
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();
0x1d, 0xc4, 0xe8, 0xc1
};
senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data));
+
+ // TODO: add method for stuffing
}
///////////////////////////////cc.e////////////////////////////////////////
}
{
- 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));
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) );
}
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'
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;
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;
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 );
}
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 );
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////////////////////////////////////////
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
}
// 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////////////////////////////////////////
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());
}
{
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);
}
///////////////////////////////////////////////////////////////////////////
// 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)
: 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()))
{}
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());
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
///@{
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
///@}
///////////////////////////////////////////////////////////////////////////
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. */
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)
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 );
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
///////////////////////////////////////////////////////////////////////////
// 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;
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;
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 ) |
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 ) |
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;
}
{
return scope() == GlobalScope;
}
-
+
prefix_ bool senf::INet6Address::linkScope()
const
{
: 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;
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;
_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());
///////////////////////////////cci.e///////////////////////////////////////
#undef prefix_
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
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
///@{
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
///@}
///////////////////////////////////////////////////////////////////////////
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
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"));
}
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
{
INet4SocketAddress addr;
-
+
BOOST_CHECK( ! addr );
addr = INet4SocketAddress("127.0.0.1:12345");
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 );
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"));
}
}
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(), "" );
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 );
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
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);
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);
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"));
// 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) );
}
}
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);
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) );
}
}
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);
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);
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();
{
using senf::MACAddress;
using senf::AddressSyntaxException;
-
+
std::string test ("A1-b2-C3:d4:E5:f6");
MACAddress mac (MACAddress::from_string(test));
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() );
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
{
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() );
}
}
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////////////////////////////////////////
>::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 );
{
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,
"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
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) );
}
}
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" );
}
" 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 );
{
{
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 );
// 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" );
// 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" );
(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 )) );
.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(
.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(
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" );
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" );
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" );
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////////////////////////////////////////
--- /dev/null
+// $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: