// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief Target.test unit tests */
+ \brief Target unit tests */
//#include "Target.test.hh"
//#include "Target.test.ih"
typedef std::string result_type;
std::string operator()(senf::log::Target::RoutingEntry const & entry) const
{
- static char const * levels[] = { "NONE", "VERBOSE", "NOTICE", "MESSAGE",
- "IMPORTANT", "CRITICAL","DISABLED" };
+ static char const * levels[] = {
+ "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" };
static char const * actions[] = { "ACCEPT", "REJECT" };
std::stringstream s;
s << entry.stream() << "-" << entry.area() << "-" << levels[entry.level()] << "-"
{
senf::log::StringTarget target;
+ BOOST_CHECK_THROW( target.route("senf::log::test::myStream", "invalid_area"),
+ senf::log::Target::InvalidAreaException );
+ BOOST_CHECK_THROW( target.route("invalid_stream", ""),
+ senf::log::Target::InvalidStreamException );
+ BOOST_CHECK_THROW( target.unroute("senf::log::test::myStream", "invalid_area"),
+ senf::log::Target::InvalidAreaException );
+ BOOST_CHECK_THROW( target.unroute("invalid_stream", ""),
+ senf::log::Target::InvalidStreamException );
+
target.route<senf::log::Debug>();
target.route<senf::log::test::myStream, senf::log::DefaultArea>(senf::log::Target::REJECT);
target.route<senf::log::test::myStream, senf::log::VERBOSE>(senf::log::Target::ACCEPT, 0);
};
BOOST_CHECK_EQUAL_COLLECTIONS( i, i_end, data, data + sizeof(data)/sizeof(data[0]) );
+ BOOST_CHECK( *target.begin() == target[0] );
target.unroute<senf::log::Debug>();
target.unroute<senf::log::test::myStream, senf::log::VERBOSE>();
target.unroute<senf::log::test::myStream, senf::log::DefaultArea>(senf::log::Target::REJECT);
- target.unroute<senf::log::test::myStream, senf::log::test::Foo, senf::log::VERBOSE>();
target.unroute("senf::log::test::myStream", "", senf::log::IMPORTANT::value,
senf::log::Target::REJECT);
target.unroute(1);
- target.unroute(0);
+ target.flush();
BOOST_CHECK( target.begin() == target.end() );
+ BOOST_CHECK( target.empty() );
+ BOOST_CHECK_EQUAL( target.size(), 0u );
}
///////////////////////////////cc.e////////////////////////////////////////