X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FLog.test.cc;h=0fbbfb9e387db0a7c78494b22e49a1b704b96d21;hb=412024ed31a4ab4eaea7a4165a434f8efebee325;hp=b4a1cbdc9829edbfcad5e71953f6cc7e0ca7f145;hpb=ae06fe86f16fdabb7ffb219d255444d2eb4f4f79;p=senf.git diff --git a/Utils/Logger/Log.test.cc b/Utils/Logger/Log.test.cc index b4a1cbd..0fbbfb9 100644 --- a/Utils/Logger/Log.test.cc +++ b/Utils/Logger/Log.test.cc @@ -1,8 +1,8 @@ -// $Id: Log.test.cc 369 2007-08-01 07:51:36Z tho $ +// $Id$ // // Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -26,36 +26,14 @@ //#include "Log.test.hh" //#include "Log.test.ih" -// We need to put all tests into this single file to not violate the ODR - -#define SENF_LOG_CONF (( (senf)(log)(Debug), (_), NOTICE )) - // Custom includes -#include "Logger.hh" -#include +#include "../../Utils/auto_unit_test.hh" #include +#include "main.test.hh" #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// -namespace not_anonymous { - - struct Foo - { - SENF_LOG_CLASS_AREA(); - - static void log() { - SENF_LOG(("Foo::log")); - } - }; - - SENF_LOG_DEF_ALIAS( LogCritical, (senf::log::Debug) (senf::log::CRITICAL) ); - SENF_LOG_DEF_STREAM( myStream, senf::log::MESSAGE, senf::log::MESSAGE, senf::log::MESSAGE ); - SENF_LOG_DEF_AREA( myArea ); - -} -using namespace not_anonymous; - BOOST_AUTO_UNIT_TEST(logger) { senf::log::StringTarget target; @@ -77,10 +55,12 @@ BOOST_AUTO_UNIT_TEST(logger) target.clear(); SENF_LOG((senf::log::IMPORTANT)("Important message")); + std::cerr << target.str(); BOOST_CHECK( ! target.str().empty() ); target.clear(); - SENF_LOG((LogCritical) ("Another log message: " << 10)); + SENF_LOG((senf::log::test::LogCritical) ("Another log message: " << 10)); + std::cerr << target.str(); BOOST_CHECK( ! target.str().empty() ); target.clear(); @@ -88,38 +68,20 @@ BOOST_AUTO_UNIT_TEST(logger) log << "Last message"; log << " continued here"; })); + std::cerr << target.str(); BOOST_CHECK( ! target.str().empty() ); target.clear(); - Foo::log(); + senf::log::test::Foo::log(); + std::cerr << target.str(); BOOST_CHECK( ! target.str().empty() ); target.clear(); - SENF_LOG((Foo)("Foo area")); + SENF_LOG((senf::log::test::Foo)("Foo area")); BOOST_CHECK( target.str().empty() ); target.clear(); } -BOOST_AUTO_UNIT_TEST(streamRegistry) -{ - char const * streams[] = { "not_anonymous::myStream", "senf::log::Debug" }; - - BOOST_CHECK_EQUAL_COLLECTIONS( senf::log::StreamRegistry::instance().begin(), - senf::log::StreamRegistry::instance().end(), - streams, streams+sizeof(streams)/sizeof(streams[0]) ); - BOOST_CHECK_EQUAL( senf::log::detail::StreamBase::nStreams, 2u ); -} - -BOOST_AUTO_UNIT_TEST(areaRegistry) -{ - char const * areas[] = { "", "not_anonymous::Foo", "not_anonymous::myArea" }; - - BOOST_CHECK_EQUAL_COLLECTIONS( senf::log::AreaRegistry::instance().begin(), - senf::log::AreaRegistry::instance().end(), - areas, areas+sizeof(areas)/sizeof(areas[0]) ); - -} - ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_