Packets: extended description of bad_cast exception in Packet.as()
[senf.git] / senf / PPI / SocketSource.test.cc
index 7daad72..ed24997 100644 (file)
 #include <boost/test/test_tools.hpp>
 
 #define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 namespace ppi = senf::ppi;
 namespace module = ppi::module;
 namespace debug = module::debug;
+namespace scheduler = senf::scheduler;
 
 namespace {
-    void timeout() {
-        senf::scheduler::terminate();
+    void runPPI(senf::ClockService::clock_type t)
+    {
+        scheduler::TimerEvent timeout(
+                "socketSource test timer", &scheduler::terminate, scheduler::now() + t);
+        ppi::run();
     }
 
     int base_pid = 0;
@@ -68,7 +72,7 @@ namespace {
     }
 }
 
-BOOST_AUTO_UNIT_TEST(socketSource)
+SENF_AUTO_UNIT_TEST(socketSource)
 {
     senf::UDPv4ClientSocketHandle inputSocket;
     inputSocket.bind(senf::INet4SocketAddress(localhost4str(0)));
@@ -81,18 +85,15 @@ BOOST_AUTO_UNIT_TEST(socketSource)
 
     senf::UDPv4ClientSocketHandle outputSocket;
     outputSocket.writeto(senf::INet4SocketAddress(localhost4str(0)),data);
-    senf::scheduler::TimerEvent timer (
-        "socketSource test timer", &timeout,
-        senf::ClockService::now() + senf::ClockService::milliseconds(100));
-    senf::ppi::run();
+    runPPI( senf::ClockService::milliseconds(100));
 
     BOOST_REQUIRE( ! sink.empty() );
     BOOST_CHECK_EQUAL( sink.front().data().size(), data.size() );
-    BOOST_CHECK( std::equal( sink.front().data().begin(), sink.front().data().end(), 
+    BOOST_CHECK( std::equal( sink.front().data().begin(), sink.front().data().end(),
                              data.begin()) );
 }
 
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #undef prefix_
 
 \f