Logger: fixed SyslogUDPTarget unit test
tho [Thu, 14 Jul 2011 14:25:25 +0000 (14:25 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1796 270642c3-0616-0410-b53a-bc976706d245

senf/Utils/Logger/SyslogUDPTarget.test.cc

index 8278eaa..e496935 100644 (file)
@@ -35,6 +35,7 @@
 #include "SyslogUDPTarget.hh"
 #include <senf/Socket/Protocols/INet/UDPSocketHandle.hh>
 #include <boost/format.hpp>
+#include "boost/date_time/gregorian/gregorian.hpp"
 #include "Logger.hh"
 
 #include <senf/Utils/auto_unit_test.hh>
@@ -68,6 +69,8 @@ namespace {
 
 SENF_AUTO_UNIT_TEST(syslogUDPTarget)
 {
+    using namespace boost::gregorian;
+
     senf::log::SyslogUDPTarget udplog (
         senf::INet4SocketAddress(senf::INet4Address::Loopback, port(0)));
     senf::UDPv4ClientSocketHandle server (
@@ -85,12 +88,13 @@ SENF_AUTO_UNIT_TEST(syslogUDPTarget)
     BOOST_CHECK_EQUAL( server.read(), "<13> Test message" );
     BOOST_CHECK_EQUAL( server.read(), "<13> Line 2" );
 
-    udplog.timeFormat("");
+    udplog.timeFormat("%Y-%m-%d");
     udplog.showTime();
-    SENF_LOG(("Very long message: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
-    BOOST_CHECK_EQUAL( server.read(), "<13> 0000000000.000000000 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" );
+    date d (day_clock::local_day());
+    BOOST_CHECK_EQUAL( server.read(), "<13> " + to_iso_extended_string(d) + " Very long message: " + std::string(896-5-10-19-1, 'x') );
+    BOOST_CHECK_EQUAL( server.read(), "<13> " + to_iso_extended_string(d) + " " + std::string(5+10+19+1, 'x'));
 }
 
 //-/////////////////////////////////////////////////////////////////////////////////////////////////