X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FLog.test.cc;h=0bec6da5070cb70c5ab6666fe191896736ae3e68;hb=f6f670f2dbc82b77db29df6cd452f2b351b9662a;hp=000164ef1064affe6265d3bd3cae0bf7aa13daed;hpb=61419d9a2e1060f7ede22fa19fd9d0b401bbc87a;p=senf.git diff --git a/Utils/Logger/Log.test.cc b/Utils/Logger/Log.test.cc index 000164e..0bec6da 100644 --- a/Utils/Logger/Log.test.cc +++ b/Utils/Logger/Log.test.cc @@ -26,20 +26,13 @@ //#include "Log.test.hh" //#include "Log.test.ih" -// Custom includes -#include - // We need to put all tests into this single file to not violate the ODR -#define _senf_LOG_STREAM logstream -namespace { - std::stringstream logstream; -} - -#define SENF_LOG_CONF (( (senf)(log)(Debug), (_), NOTICE )) +#define SENF_LOG_CONF (( (senf)(log)(Debug), (_), NOTICE )) \ + (( (not_anonymous)(myStream), (not_anonymous)(Foo), VERBOSE )) +// Custom includes #include "Logger.hh" - #include #include @@ -66,30 +59,47 @@ using namespace not_anonymous; BOOST_AUTO_UNIT_TEST(logger) { + senf::log::StringTarget target; + + target.route(); + target.route("not_anonymous::myStream", "not_anonymous::Foo"); + + // We cannot easily check the exact log string since that includes the current date/time + SENF_LOG_DEFAULT_STREAM(senf::log::Debug); SENF_LOG_DEFAULT_AREA(senf::log::DefaultArea); SENF_LOG_DEFAULT_LEVEL(senf::log::VERBOSE); - // should be disabled SENF_LOG(("Log message")); + BOOST_CHECK( target.str().empty() ); + target.clear(); + SENF_LOG((senf::log::VERBOSE)("Log message 2")); - // should be enabled + BOOST_CHECK( target.str().empty() ); + target.clear(); + SENF_LOG((senf::log::IMPORTANT)("Important message")); + BOOST_CHECK( ! target.str().empty() ); + target.clear(); + SENF_LOG((LogCritical) ("Another log message: " << 10)); + BOOST_CHECK( ! target.str().empty() ); + target.clear(); SENF_LOG_BLOCK((senf::log::Debug) (senf::log::IMPORTANT) ({ log << "Last message"; log << " continued here"; })); + BOOST_CHECK( ! target.str().empty() ); + target.clear(); Foo::log(); - SENF_LOG((Foo)("Foo area")); + BOOST_CHECK( ! target.str().empty() ); + target.clear(); - BOOST_CHECK_EQUAL( logstream.str(), - "Important message\n" - "Another log message: 10\n" - "Last message continued here\n" - "Foo::log\n" ); + SENF_LOG((Foo)("Foo area")); + BOOST_CHECK( target.str().empty() ); + target.clear(); } BOOST_AUTO_UNIT_TEST(streamRegistry)